Basically I've created a project from 0 using Visual Studio 2010, a simple aspx (with his aspx.cs and .designer behind) which needs to call a library located in the same project folder /bin/libraryName.dll.
I right-clicked on my project and added the reference.
I even added the following lines to make sure my project could see the .dll file:
if (File.Exists("B:\\mk2015\\web\\Simposium2015\\bin\\DecoderEndeavour.dll"))
{
Response.Redirect("Found.html");
}
Inside the /bin/LibraryName.dll path on my Project Explorer I could see now a LibraryName.dll.refresh file was created, that simply has in him the path pointing to where the .dll is located.
I tried to execute the code:
LibraryName.Class1 Decoder = new LibraryName.Class1();
And I got the following error:
The system cannot find the file specified. (Exception from HRESULT: 0x80070002). From the FileNotFoundException.
I'm completely lost, in some way my code is able to verify a file is there, he can see it, but somehow it's not correctly linked to some part of the project as then it doesn't find it when trying to create a class declared inside the library.
Can anyone help?
Thanks!
Related
Following on from my issues with a simple Visual Studio Installer Package, I'm making the switch to WiX. The learning curve is annoying, because once I've set this up I'm going to forget how it works before I need to do it again next project. But anyway, here we go.
My environment is Visual Studio 2019 and Azure DevOps (the full TFVC). The projects involved are class libraries and a WPF application all written in C#. I also have the WiXWax extension thingy to give me a GUI for adding projects and dependencies quickly.
When I created my WiX project I stupidly included a typo in the name of the project and consequently in the underlying folders. When I noticed this I decided to fix it;
Unload the projects
Using the source control explorer, rename the folder
Using notepad, open the sln file and correcting the path to the project, and the project name
Using notepad, open the project file and correct its references to the path and project name
Rename the project files
As you can see I have changed every reference to the the incorrect spelling.
Unfortunately, Visual Studio won't load the project. I get an error telling me this:
C:(correctly spelled path that matches the file system and file names).wixproj
: error : The project file
'C:(path with a typo in it)(correctly spelled project name).wixproj'
has been moved, renamed or is not on your computer.
Now the message is partly correct, because the file it says has been moved or renamed has in fact been renamed. If I click on the error it opens the wixproj file (it's just an xml of course). This file doesn't have a self referenced location though, the only things that's close is the include to the projects which haven't changed and are correct (..<correct detals>.csproj)
I have opened every xml file including the solution files and wix project files and none of them contain the typo (Ctrl+F, case insensitive, not whole word - no results).
I have tried "Removing" the WiX project from the solution and re-adding it, but I get the same error and it doesn't add it to the solution file.
What is remembering the old path name, and how can I make it forget it?
edit: I've also tried Ctrl+Shift+F per Klaus' suggestion and it finds no references.
So I have a C# project and I'm trying to add USB functionality to it via the Silicon Labs CP2112 USB to i2c bridge. They provide drivers as 2 .dll files: SLABHIDtoSMBus.dll and SLABHIDDevice.dll (which apparently is needed at runtime). I've also found a SLABCP2112.cs file that is supposed to allow the dll to be used in C#.
I've added the SLABCP2112.cs to my project successfully and Intellisense recognizes the functions. The problem is that when I run the program it always throws an exception that the SLABHIDtoSMBUS.dll is not found(System.DllNotFoundException). I've tried moving the dll to various locations such as the main project folder, the 'USB' folder in the project where I've included the SLABCP2112.cs, the Windows SysWOW64 folder and finally in the c#'s projects 'bin' folder.
Placing it in the bin folder still throws an exception but changes the error to a bad image error or something similar. For good measure I've tried to add the .dll's as References in the project but this causes an error "invalid or unsupported type".
I'm assuming the problem is still that the compiler doesn't know where to look for the dll files, so where should I put them? Or if not, how do I get this working?
BACKGROUND
I'm mostly programming in embedded C/C++ but sometimes I have to do some C# programming for our API. For this I'm using Visual Studio 2017 to create an API DLL for our customers.
The C# API and our C/C++ firmware are using a common set of status codes. I have a Lua script that generates these codes to a .h (for C/C++) and a .cs (for C#) file so they always are in sync.
All source files that are shared across products and platforms are in a special project called "Common" (checked-in to Subversion).
When we create new projects and use any "common" file, we put them in a sub folder called "Common\" so we know that there is no point in messing with them. Subversion will check out these "Common" files as externals of a specific revision used by each project.
In C/C++ it's no problem at all to have source code organized in several levels of folders, all source files have a relative path to the root project folder.
THE PROBLEM
So in this C# project I organize the source code as usual:
ProjectRoot\source.cs
ProjectRoot\Common\EStatusCodes.cs
In the ProjectRoot\ we have all .cs files for this C# project, and in ProjectRoot\Common\ are the external files from subversion's "Common" project.
So after the checkout of the external EStatusCodes.cs into the ProjectRoot\Common\ folder I add it to the C# project by "Add->Add Existing..." and then I point out the ProjectRoot\Common\EStatusCodes.cs file.
The file shows up in the Project but for some reason Visual Studio has COPIED the file form the ProjectRoot\Common folder to the ProjectRoot\ folder and is then using the copy! (The file's path in properties is set to the ProjectRoot\ folder.
So If we add more status codes to the "Common" project, this C# project don't get the update because Visual Studio now always use the copied version of the file from ProjectRoot\ and don't care if ProjectRoot\Common\EStatusCodes.cs has been updated.
I tried to add the Common folder to "Properties->Reference Path", but it still copies the file every time I add it to the project.
Is it possible at all to have source files somewhere else than in the C# project's root folder?
In the Add Existing dialog, there should be a small down arrow next to the Add button. If you click this, you'll see an option to "Add As Link". This will add the file as a reference link to the original file and any changes to the original will reflect in your project.
We have a similar way in C# project: add existing file to project as "Add as link".
Please refer this link for more details:
https://grantwinney.com/visual-studio-add-file-as-link/
To start, I have read tons of questions like this but nothing has fixed my issue. When I publish my project from Visual Studio 2013 to a server, I get the following error:
Its apparently missing a reference to a library I'm using. The issue is the dll is getting published (it is in the bin folder on the server). It seems its having some issue finding the reference? I've tried copying the dll and putting it in the same directory as the c sharp code. I've made sure everything is using the same framework. I have no idea what's happening. I need some help. Thanks in advance!
Here is the bin folder:
Here is the folder on the server:
As you can see the project is very small right now.
Here is the Default.aspx code:
Here is the C# code (Default.aspx.cs):
And here is my web.config:
It is because the DbAccess dll is not getting the path
you need to make a folder in your solution and give any name like "ThirdpartyDll".
Paste your dll in this folder and while adding new dll give reference path from this folder and then publish.
On server application will take the same path, which i think you had given from local.
I made the mistake of not formatting the directory on my server using IIS. If anyone comes across this make sure you do that!!!
I have an annoying error that's been popping up, and I don't know where it is coming from. The error is:
Error 31 Unable to copy file "app.config" to "bin\Debug\Framework.Tests.dll.config". Could not find file 'app.config'. Framework.Tests
The problem is, I don't have a bin\Debug folder anywhere, and it does not say from where it is trying to copy app.config. Double clicking on the error doesn't bring me to any code where it is trying to copy, so that doesn't help me either. So I don't know where I should make the app.config.
How can I find this out?
You have added a reference to a file called app.config or Visual Studio did this for you. The file does not exist on the disk, presumably because after adding the reference you later deleted the file.
Search for the missing file in your Solution Explorer, and either delete the reference or create the file.
It is most likely in the root folder of one of your projects, and should have a yellow triangle warning icon showing that the file is missing.
In an MSTest project the app.config is the one that you would like to provide any calls to the ConfigurationManager class.
It resides in the root of your test project.
The bin\debug folders will be created once the project compiles for the first time. Show all files in the solution explorer should help as they are not (and should not) be included in the project.
HTH
You probably do have a bin\Debug folder beneath your project folder, being the build target folder created by Visual Studio when you build your project for the Debug configuration.
My guess is that something (a test framework perhaps) still has the DLL file loaded, so Visual Studio can't delete and replace the existing Framework.Tests.dll.config file with the contents of your app.config. [Note: the project build action for app.config files is to copy it to the target folder renamed to match the executable with an extension of .config appended.]