Regasm.exe only works in Debug output folder, not install folder - c#

I am writing an add-in dll in c#, VS2012, Win 7 x64. Debugging has been fine; VS registers the dll at the end of building and I've also set up a batch files in my project folder to register and unregister the assembly.
"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regasm.exe" /codebase ".\bin\Debug\MyAddin.dll"
This will work every time. FYI my development files are also on a network drive and they will register. Even changing to an absolute file path for the dll works.
Now I am working on deploying the add-in, so I'm starting with WIX to create the installer MSI to put the files in the correct install folder. This is where I start getting the RA0000 "Unable to locate input assembly 'MyAddin.dll' or one of its dependencies." error from regasm.exe when I run from a batch file in in my project folder to register the files once they are installed.
"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regasm.exe" /codebase "C:\Program Files\Suite Folder\Product Folder\MyAddin.dll"
This never works. I could see if regasm never worked, but anywhere outside of the output folder won't. So here is what I've tried so far.
Since my Debug output folder has other files like the .tlb and other stuff I started deleting them one by one all the way down to my add-in and the dependent .dlls. Just to verify what files are really needed to register in the output folder.
I thought maybe WIX was not creating the files correctly so I copied all the files including the .tlb and others from my output folder into the install folder (I know these should not impact anything but just to be thorough)
I've unregistered the dll after VS builds thinking that more than one register was the problem.
Tried running regasm from within the install folder directly so it could find all dependencies there.
Made sure all of my dlls are x64 platform.
Tried all lines from batch files in CMD window (w/ and w/o run as admin).
File attributes from output to install folder are the same.
Any ideas?

Related

What is Microsoft.Common.CurrentVersion.targets and what is it used for?

I was in hot pursuit of a big mystery in a Visual Studio 2022 C# testing project that I didn't originally create. I couldn't figure out how a certain EXE in a folder was making its way into the bin folder when I did a build. This EXE was not being produced by the build, but was part of an external tool that happened to be in a Lib folder within the solution folder. I had removed a reference to this EXE from the csproj file and thought everything was good to go to prevent it from being copied to bin. However, every time I would do a build, that same exe file would still get copied to my bin folder. I could not figure out for the life of me how this EXE file was getting copied into the bin folder. There was a DLL that I was using that the EXE also uses, but I didn't think including that DLL in my project would cause the EXE to get copied with it.
Finally I decided to create a dummy file in the bin folder with the same EXE name and make it read-only. I did the build and suddenly a file-write error occurred in C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets file.
So, I had found the culprit, but then it raised a question..., What exactly is C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets doing? Is it somehow automatically copying files into the bin folder? Seems like there is some black magic going on behind the scenes at it is confusing the heck out of me!

Running C++ Redistributable files from a Probing Folder

I'm currently having an issue with "Probing" dlls from another folder. Specifically the C++ Redistributable files that my application is dependent on and that I have just included in my folder to avoid having to run an installer.
The application runs successfully if these files are in the same folder as the exe:
msvcp110.dll
msvcp120.dll
msvcp140.dll
msvcr110.dll
msvcr120.dll
vcruntime140.dll
However when I in my App.config of my application try to probe dlls to 2 other folders, none of them is loaded upon execution of the .exe.
<probing privatePath="DataResources/cefsharp;DataResources/miscellaneous" />
The DLLS are located in the DataResources/miscellaneous folder. The DLLS from DataResources/cefsharp (which are some of my other dlls) ARE loaded however.
Does anyone know what the issue could be?
Thank you very much!
So it turns out that when it comes to these files, CefSharp is dependent on them being in the exact same folder as the CefSharp files themself. In my case, moving these files to the CefSharp folder did the trick.
This is probably not the case in others circumstances but if you are using CefSharp are having this same exact problem, that's why.

Could not load file or assembly 'accord.video.ffmpeg.x64.dll' or one of its dependencies

I'm using Accord.video.ffmpeg.x64. My project is built in x64 as well. It is a click once windows forms application. I installed accord through nuget. C++ redistributor is installed.
Everything works fine when I run the program from debug. But when I publish it and try to run it (on the same machine or any other machine) I get the error "could not load file or assembly 'accord.video.ffmpeg.x64.dll' or one of its dependencies."
Thank you for any help you can provide.
Install on the machine both
vc_redist-2015.x64.exe
vc_redist-2015.x86.exe
and copy all files from your Nuget packages folders
packages\Accord.Video.FFMPEG.x64.3.8.0\lib\net(Version)
packages\Accord.Video.FFMPEG.x64.3.8.0\build
to the installation folder of your application.
I had the same issue this week, but I found the solution! When I compared the files in the bin folder vs the application directory under programs files, the bin folder had 8 additional files that weren't in the application installed folder:
avcodec-57.dll,
avdevice-57.dll,
avfilter-6.dll,
avformat-57.dll,
avutil-55.dll,
postproc-54.dll,
swresample-2.dll,
swscale-4.dll,
These files need to be copied into the application install folder. They can't be referenced since they aren't .net they are c++ dll. So what I did was added the dll files directly to my project , then right click each file properties and for build action I selected "content", then for copy to output directory, I put "copy if newer." This fixed the issue for me, so I hope it works for you too!

Register custom C# assemblies in the GAC

I wrote some codes with C# and make dll files.
When i put my Application on another system my application needs dll files beside the .exe file.
I know that some dll files copy to GAC and the exe file doesn't need the files anymore.
I also know if dll is type of ActiveX or COM we can use regsvr32 or regAsm.
But i don't know how i can register my own dll files in windows.
You need to open the command prompt which comes with VS.
You need to use the gacutil tool
gacutil /i myown.dll
For more info:
http://msdn.microsoft.com/en-us/library/ex0ss12c%28v=vs.80%29.aspx
You can refer this page for doing so programmatically:
http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/7d3165cf-ca3b-43cc-8f77-a46dbf38f13d/
You can otherwise use Microsoft Windows Installer for deploying your application :
http://codefornothing.wordpress.com/2007/11/27/short-msi-tutorial/
And you can find the MSI here, if need be.
http://www.microsoft.com/en-in/download/details.aspx?id=25#overview

Find out all the files required to run a c# application

I need to generate a list of all the files which are enough to run my application on any machine. I need this for a setup program. When i go to bin/release folder i'm able to see some pdb files and some configuration files, which i think will not be needed. I tried to disable generation of pdb files too but it still generates pdb for the other projects present in the solution.
So i need a way in visual studio 2008, which can get me all the files (the .exe and .dll and other files) required by my application to run.
Thanks.
Have you tried publishing the application (Build > Publish [app])?
This should just copy all the essential files to the specified folder.
The pdb files are used for debugging. Building in "Release" mode should exclude these files.
You can also create a setup project within the solution. Using that project it is possible to see a list of included files.
If you make a release build or publish the application then you should have a complete set of assemblies your application needs.
However, it can still rely on assemblies which reside in the GAC (Global Assembly Cache) of your machine. Check the references of your project if you think there are assemblies missing in the bin folder.
To solve this exact problem with our software, we wrote a simple console app that finds all the .vbproj & .csproj files in our projects directory, then changes all of the to Release mode (which does not create pdb files, documentation files etc).
This is then run by the build machine (CruiseControl.Net) before it starts compiling the projects.

Categories