Forced to manually delete DLL file on each build - c#

I'm building a DLL as part of a plugin for software called Navisworks. When I try to build the DLL I get this error:
Error Cannot register assembly "C:\Program Files\Autodesk\Navisworks Manage 2021\Plugins\Zoney2021\Zoney2021.dll". Could not load file or assembly 'Autodesk.Navisworks.Api, Version=18.0.1347.51, Culture=neutral, PublicKeyToken=d85e58fa5af9b484' or one of its dependencies. The system cannot find the file specified
I've researched this error plenty and found no obvious solution to it. The referenced assembly is in the right directory and has "copy local" and "specific version" set to false. I've used dependency walker and there are no subdependencies. If I manually delete the Zoney2021.dll the program will run and load the build DLL properly. This shouldn't be a permissions issue since I always run Visual Studio as admin. If there's no easy solution, can I have a script that autodeletes the DLL on each build?
Thanks

If you want to delete the file automatically before each build, open your startup project's properties and go to the Build Events tab. There, you can enter a command to delete it.
Something like:
cd "C:\Program Files\Autodesk\Navisworks Manage 2021\Plugins\Zoney2021\"
del Zoney2021.dll

Related

Export or execute a console application form project

How do you save your console application as exe program?
I have found the exe file within the Debug folder, but returns an error when executed.
Error message –
Could not load file or assembly 'Ionic.Zip, Version=1.9.1.8, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c' or one of its dependencies. The system cannot find the file specified.
I’m using the Ionic library, I think I need to package the whole program, not sure how to do this?
Right click on the your project on the solution explorer
On configuration choose release
Now you will find a release folder next
to the debug folder use the .exe inside it

Referencing dll files - my AutoCAD plugin only works on my computer

I have created an AutoCAD plugin, but encounter problems when using the plugin on certain machines. It works fine on my machine.
One thing that I have noticed is that if I change the output path of the build to a different directory I get problems stating that certain namespaces cannot be found.
The following shows the build output folder with the dll files in, the build is successful.
http://imgur.com/5va3ePj
However, if i build to an empty folder (even with dll files referenced) i get the following errors and warnings...
http://imgur.com/eM86l0u
This plugin needs to be able to be used by other users, i think im not referencing dll files properly or something as the program only runs successfully on my computer (and all computers that i have opened the solution in visual studio and built to the export folder). Copying all the files shown in the folder above to the same path on another users computer doesn't work, other users get an error stating 'Could not load fil or assembly "c:/info3d/info3dreloaded.dll" or one of its dependencies. Operation not supported. Exception from HRESULT: 0x80131515)'
Thanks in advance for any help!
Chris
For AutoCAD DLLs set the Copy Local to false. AutoCAD provides those via its runtime.
"Once a AutoCAD .NET API DLL is referenced, you must set the Copy Local property of the referenced DLL to False." from http://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2015/ENU/AutoCAD-NET/files/GUID-8657D153-0120-4881-A3C8-E00ED139E0D3-htm.html
Right click on the reference and click on properties and set the "copy local" property to true

"PDB does not match image" error in C# VS2010 project

I've been using a library in my code base for a while now, and I wanted to debug right into the library level. To do that, I downloaded the source code and included the project as an existing project into my C# solution. I then had my other projects reference that project instead of the downloaded .DLL.
Once the project was referenced instead of the DLL, I ran my solution through the debugger and tried to step into a function call that would have called into the external project, but it stepped right over it. While debugging, I opened up the "Modules" window and saw that the DLL's Symbol Status read "PDB does not match image", which is the likely cause of not being able to debug this project.
My question is simple, why does the PDB not match the image if my project is directly referencing the .csproj file as a reference? There should never be any ambiguity as to what version to run.
I've run into this issue before when I have another project open that also references the DLL and uses its debug info (PDB). Basically the other project puts a file lock on the PDB in the referenced project and when you compile or debug the referenced project, it quietly fails to generate an up-to-date PDB file.
If this is what is going on, make sure you have no other apps running or instances of VS open that reference your DLL, and then seek out and delete all copies of the PDB from beneath the BIN and OBJ folders, then recompile it.
I hope that helps.
Sometimes it happens because you might have build the project as a release.
Right click on the solution and click on "Batch Build" > Check all your projects and click "Clean"
For me this happened for an Excel Add-In. I went to the modules window to see why it wasn't loading for my dll. I looked at the folder where the .dll was located and went to that location. There was an .ini file in that location. Opening it revealed the install location of my application, which turned out to be in "C:\Program Files\" as opposed to the bin\debug location of my project.
Basically I had an old version of the add-in already installed that was getting loaded up upon me trying to debug the project. I uninstalled the old project, deleted the old .dll location in "C:\Users[user]\AppData\Local\assembly\etc..." and voila, the debugger loaded up the newly compiled dll.
Faced same issue, it was due to old assembly and latest PDB. There was mismatch between both.
The assembly was built properly, but again my post build dll copy script was overwriting it with older one.
Removing the dll from post build script resolved issue.
Need to ensure that dll or pdb are up to date when debugging finally commences.
This happened to me today while I was trying to debug notepad++ dll plugin , I had to change build output directory to notepad++'s plugins directory and set the Debugger to launch notepad++ instead of the current project dll to proceed with set breakpoint. This had me nuts as Visual Studio 2019 was telling me that SYMBOLS were not loaded for the plugin dll which I was trying to debug.
Finally checking the modified date and time as others here suggested, made me realize the pdb was not up to date with the the build output dll timestamp. I tried rebuilding the solution but the pdb generated has same older timestamp though I delete them manually and initiate build. So all I had to do was to make a change in the source code by deleting a white space and rebuild. Voila! this time I got the debugger to load the symbols for my dll automatically and hit the set breakpoint.
Maybe cleaning the solution also might have worked.

Error when creating Excel document using NetOffice Interop

I am getting the following unhandled exception when I try to create an excel document using my c# application. This process works fine when I am running the c# application from visual studio 10, but when I try to run the application outside of visual studio using the .exe file this error is appearing.
System.IO.FileNotFoundException: Could not load file or assembly 'ExcelApi, Version=1.5.1.2, Culture=neutral, PublicKeyToken=9084b9221296229e' or one of its dependencies. The system cannot find the file specified.
File name: 'ExcelApi, Version=1.5.1.2, Culture=neutral, PublicKeyToken=9084b9221296229e'
Apparently your project has an assembly called ExcelApi.dll which is missing on the target machine. I assume this is a NetOffice dll, which is required in the output directory for your project to run.
Open your project directory (depending on your VS version, you can right-click the project in Solution Explorer and choose Open Folder in Windows Explorer). Go into the \bin folder, then into the folder that matches your build configuration (most likely Debug, but it might be something else depending on how your project is set up). In that directory, copy all of the .exe, .dll, and .config files to the directory you're trying to run your program from.
In particular, you will need at a minimum your executable and config file, along with ExcelApi.dll, OfficeApi.dll, VBIDEApi.dll, and NetOffice.dll. See here for details.

Add DLLs folder

I have a c# .net app.
I'm using a WebKitBrowser.
The problem is that the app does not work if i don't put all the webkit DLLs into the debug/release folder.
What i'm trying to do, is to put all these files into a folder like debug/WebkitFiles and all the files to be token from there.
Any help? thanks
This should help:
<probing> and <privatePath>
Read up on the <assemblyBinding> tag in MSDN as well:
Note the changes go into your app.config file.
You can xcopy the files in your post-build event, under the project properties
Additionally, how did you first referenced the WebKitBrowser DLLs?
If you expect .NET do bind to an assembly but it is failing, do the following:
1. Open the Visual Studio Command Prompt
2. Type 'fuslogvw'
-- every load of an .NET assembly will be registered in the console
Put your DLLs where you want then add a reference to them and set "copy local" to true. If you want to keep dependencies in a sub-folder you have to modify your assembly manifest file.

Categories