Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello,

 

I have developped an application which let the user define its own mathematical functions using a subset of VB.Net. I then use Codedom to compile each function into its own assembly. When the user launch a calculation, I load the needed assemblys and use the defined methods.

 

Everything works fine as long as the user don't try to recompile a function (an assembly) which has been loaded in memory.

I have not been able to find a way to "unload" an Assembly. As of now, the user has to quit the application and relaunch it (not the optimal solution...) .

 

Does anyone has an idea on how to solve this issue?

 

Thanks for your help

 

Pierre

 

PS : To solve this, the only thing I can think of is to launch another application which would load the assemblies, do the calculations and then communicate the results to the original app, but I have not been able to find any exemple on how to do that so far.

Posted

Oops ... Sorry I pressed enter a bit too fast.

 

As I was saying, I have been looking into that. Unfortunately, I can't seem to find any exemple in VB which would detail something like that and the documentation... well as usual, it is very good when you know what you are lokking for but as for concepts, it is a bit on the short side.

 

If you have any link to a good exemple, that would help a lot.

 

Thanks

 

Pierre

  • *Gurus*
Posted

Well, when I was looking through msdn.net, I looked at the

CreateDomain method of the AppDomain class. It seems like

you just declare a variable of type AppDomain and use the

CreateDomain method...

Dim myDomain As AppDomain = AppDomain.CreateDomain("NewDomain")

Then I assume all properties and methods of the class would be

available for myDomain, like myDomain.Load(Assemblyname) and

maybe myDomain.ExecuteAssembly("myassembly") or

myDomain.DoCallBack(callbackdelegate)

 

Here is just a bit of code from MSDN...

Public Module PingPong

  Private greetings As String = "PONG!"
  
  Sub Main()
     Dim currentDomain As AppDomain = AppDomain.CurrentDomain
     Dim otherDomain As AppDomain = AppDomain.CreateDomain("otherDomain")
     
     greetings = "PING!"

     MyCallBack()
     otherDomain.DoCallBack(AddressOf MyCallBack)

     ' Output:
     '   PING! from default domain
     '   PONG! from otherDomain
  End Sub 'Main
  
  Sub MyCallBack()
     Dim name As String = AppDomain.CurrentDomain.FriendlyName
     Console.WriteLine(greetings + " from " + name)
  End Sub 'MyCallBack

End Module 'PingPong

And, of course the the Unload method to shut the AppDomain

down (gracefully - must be done executing I believe).

Posted

Thanks, looks like that was the right path to follow

 

I have been playing with the domains and it seems to work.

 

The only remaining problem I seem to have is that when the process in the created appdomain takes too long, I seem somehow to get "disconnected".

 

I guess it must be due to some Remoting problem between the two appdomain.

 

I am going to dig into the documentation....

 

Thanks again

 

Pierre

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...