// CSharpServer.cs // compile with: /target:library // post-build command: regasm CSharpServer.dll /tlb:CSharpServer.tlb using System; using System.Runtime.InteropServices; namespace CSharpServer { // Since the .NET Framework interface and coclass have to behave as // COM objects, we have to give them guids. [Guid("DBE0E8C4-1C61-41f3-B6A4-4E2F353D3D05")] public interface IManagedInterface { int PrintHi(string name); } [Guid("C6659361-1625-4746-931C-36014B146679")] public class InterfaceImplementation : IManagedInterface { public int PrintHi(string name) { Console.WriteLine("Hello, {0}!", name); return 33; } } }
IManagedInterface* iFace = NULL HRESULT hr = ::CoCreateInstance(GUID1,GUID2,reinterpret_cast<void**>(&iFace)); iFace->PrintHi("HI"); int n = iFace->Release(); CoUninitialize(); hr = DllCanUnloadNow(); CoFreeUnusedLibrariesEx(0,0); now my requirement is to delete the COM Interop DLL BOOL b = DeleteFile("COM interop dll's path");
MSDN
DllCanUnloadNow
CoFreeUnusedLibrariesEx
S_OK
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)