Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my code im importing a DLL using DllImport("OTVPlayer.dll")] and using its methods. How can I dispose this DLL after using? Please help. very urgent
Posted
Updated 12-Jan-12 2:57am
v2

1 solution

In .NET you cannot unload modules/assemblies unless you unload all AppDomain. The unamanaged libraries should be released when calling assembly is unloaded.

Try to create a new AppDomain, do your stuff and when you finish, unload it. It's not nice, I know.
 
Share this answer
 
Comments
Member 8089914 12-Jan-12 9:44am    
Can you give me more details ? a reference also be fine
Catalin Serafimescu 12-Jan-12 9:48am    
http://stackoverflow.com/questions/97433/good-example-of-use-of-appdomain
http://msdn.microsoft.com/en-us/library/system.appdomain.aspx <-- lots of samples

http://blogs.msdn.com/b/cbrumme/archive/2003/06/01/51466.aspx
Andreas Gieriet 12-Jan-12 14:42pm    
Hi Catalin Serafimescu,
why "not nice"? It's problably the only way to do it.
Cheers
Andi
Catalin Serafimescu 12-Jan-12 16:17pm    
The objects needs to be marshaled. And you can't do that with any objects. And, compared with 'regular' programming, it's more complicated.
Also, from the name of the DLL I suspect this is some player. Not sure, but I think streaming is impossible between domains. In any case, I wonder why unload the player DLL...
Member 8089914 13-Jan-12 0:08am    
thank for everything. Actually to clarify you more this is a DLL intergrated with a player. Im passing the parameters to the DLL and the DLL shows the corresponding video stream in the player.but I can see DLL is still have a reference to my application although I close the related windows form. I dont want this and I want to release the DLL. this is the problem Im having.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900