Click here to Skip to main content
15,907,000 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have created a DLL (introp layer (C++)) which responsible for compiling un-managed code (in c).
I am adding this Dll into a C# windows form application.

Now my requirements is

I need to modify the intorp layer DLL as per some checked list and same DLL should be replaced in C# windows form application where it get referenced.

In short i want remove a Dll which is Being used in a Application.

What I have tried:

[DllImport ("kernel32.dll" , SetLastError = true , CharSet = CharSet .Unicode)]
static extern bool MoveFileEx(string lpExistingFileName, string lpNewFileName,
MoveFileFlags dwFlags);
static void Main(string [] args)
{
string fileName = @"e:\1.wav" ;
MoveFileEx(fileName, null , MoveFileFlags .MOVEFILE_DELAY_UNTIL_REBOOT);
}

--------------------------------
File.Delete(filename);
--------------------------------
GC.Collect();
GC.WaitForPendingFinalizers();
FileInfo f = new FileInfo(@"D:\New folder\Test0001.wav");
f.Delete();
--------------------------------
Copy to new file and delete
--------------------------------
rename to new file and delete
Posted
Updated 7-Mar-16 23:21pm

1 solution

Once it's loaded, an assembly is locked for the lifetime of the AppDomain. You can't replace the file without first unloading the AppDomain.
 
Share this answer
 

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