Visual studio: Build action=Content causes error for dll file - c#

I am trying to build a project in C# which uses some unmanaged dll files (MSVCRT.DLL, DFORRT.DLL, ...). There is no direct reference to the MSVCRT.DLL file in the project(this file is referenced by another dll and not directly by my program)
I want this dlls to be copied to bin directory. if i set build action to Content i get this error on run time:
The procedure entry point _wcstoui64 could not be located in dynamic link library msvcrt.dll.
Which is weird. I cant use other build actions because i want my dlls to be published too(Build action=None wont cause any error but doesn't let me to publish my dlls)
If i completely remove all references to all the dlls and treat them like data files, or pictures(files that are not used in code but should be copied to the output) again i get the same error.
What is causing the problem? how can i publish my dlls?

Related

c#, how to add a binary dependency file safe as resource to the EXE in designer

my visual studio project has some includes (i use the .net framework 4.6.1).
So I wanted to do a loader in .net 2.0 for unpacking the needed files without admin rights into a user folder with the EXE together.
My idea was to add them as type "FILE" resource into the "loader" project and then extract them as a file again in the user directory together with the .net 4.6.1 EXE. As soon I add one of the files to my NET 2.0 loader project as resource in the designer, the whole project is broken and spits out errors, which I do not understand.
How I can add a complex file as a resource in my project (DLL / EXE)? Simple TEXT-Files work so far. (The extracting routine works also). I get the error right after adding a binary dependency file (DLL) like "System.Data.dll". It says after adding the resource that I have a wrong reference or something alike. The project becomes immediately unusable after it with that error persisting. If I delete the file out of the resource again, the error persists. I have to start all over again with the project.
Any ideas?

Getting error "Unable to load DLL 'SQLite.Interop.dll'" despite it being in the bin folder

I have a ASP.Net Web Project and used NuGet to include System.Data.SQLite.
That shows under my references but when I publish my app (via "File System") and go to the controller "http://localhost/api/test", it shows the error:
Unable to load DLL 'SQLite.Interop.dll' The specified module could not be found.
I noticed, in my project's bin\Release\net452\win7-x86\x64 the DLL is there, but in the website's actual bin folder, the interop dll is not there!
How do i get it to be included? (I tried adding it as a reference and it wouldn't let me)
Find the location of the interop.dll and add it to the project, then select copy always. This will force the publishing profile to copy it to your deployment.

Could not load file or assembly, newtonsoft.json

I have a c# console application that is using JSON and it works fine when run on my development machine. When i try to move the application to another machine to run it i get the following exception when it comes to the part of my code which requires json:
Could not load file or assembly, newtonsoft.json 4.5.0.0
I presume i need to download/install this on the machine i want to run the application on. How would i go about doing that?
Download the Newtonsoft.Json.dll from http://json.codeplex.com/releases/view/107620 and place it in application's BIN folder.
Locate the missing assembly in the solution explorer (under references), right-click and select properties, then select
copy local: true
and the dll will be copied to your output folder and should be distributed with your program.

Teamcity/c# build doesn't copy my DLL to the bin folder

I have a C++ wrapper DLL added to one of my projects, the proect is my "Set as startup" project.
To do this I just right clicked on the project and did "Add exisitng item" and then in the properties I have
Build Action = None
Copy to Output Directory = Copy always
The code in this project does not directly use this dll, it's used in another project that's part of the solution and I cannot add it to the References as it's not a proper .NET dll.
My TeamCity build doesn't include this dll when it builds my project and I don't know why. I changed the build script so that it just copies the dll from a location to the bin folder but that doesn't work, when I run my app I get a run time error "could not find dll" even though I can actually see it in the bin folder.
So I cannot just copy it to the bin folder, I need to tell Team City to include that dll when the project is built, as it does when I compile it from Visual Studio
So my question is how can I tell Team City to include the dll when it complies my project?
I'm using VS2010, .NET 4

C# solution referencing a pre-built .exe

I have a project which is the core of our application. We build several DLLs and an EXE.
We then have custom projects which use pre-built core DLLs and EXE and add customisations/extra bits as required. These customisations are always DLLs, the core EXE is always used. The core DLLs/EXE are referenced by the custom solution.
I'm having a bit of a problem while debugging getting the custom DLLs to load. Because the EXE is pre-built we use one the projects as the startup project which points to the location of the EXE and the rest of the DLLs. However it then doesn't seem to the load the startup project DLLs.
How should I be setting my custom solution/projects up when the EXE is already built?
(NOTE: the custom DLLs provide components which are loaded reflectively from metadata if you're wondering)
UPDATE: Current approach is to have a post-build event in the "top-level" project of the custom solution which copies all the core DLLs and EXE into the bin/Debug directory. Then set that top level project as the startup project and point to the copied EXE in bin/Debug. It then finds the DLL because it is in the same directory as the EXE (along with all the others).
Selecting a DLL as the startup project does not in any way guarantee that it actually gets loaded. That EXE you are using has to use Assembly.Load/From() to get the DLL loaded. At that point does the debugger step in and activate the break-points you set.
Easy to tell from the Debug + Windows + Modules window. If you don't see your DLL loaded in that window then nothing is going to happen. You'll need to find out what the exact configuration rules are for that EXE so that it will load the DLL you want to debug.
You can run the .exe, then attach Visual Studio Debugger to the process. Make sure the .pdb for your .dll is in the executing directory.

Categories

Resources