0

I have the following code in a C++ DLL. It loads and invokes a method in a DotNet DLL built with C#.

Assembly^ a = Assembly::LoadFrom(gcnew String("MyDotNet.dll"));
Type^ type = a->GetType("MyAssemply.Assembly");
MethodInfo^ method = type->GetMethod("MyMethod");
Object^ obj = Activator::CreateInstance(type);
array<Object^>^ params = gcnew array<Object^>(0) {  };
Object^ ret = method->Invoke(obj, params);

The problem is that it does not appear to release the resources or DLL even when I do a FreeLibrary on the C++ DLL. Is there a API or Method I need to call to release the DLLs/resources?

I am using Visual Studio 2010.

Thanks.

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
Neil Weicher
  • 2,370
  • 6
  • 34
  • 56

1 Answers1

1

You can't unload a managed assembly from an app pool. You can create another app pool and unload that.

This post is related: How to unload an assembly from the primary AppDomain?

Community
  • 1
  • 1
Daniel A. White
  • 187,200
  • 47
  • 362
  • 445