Compiled application does not work in it's own folder [closed] - c#

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
The application that I've released works very well in any folder, except:
E:\Csharp\NewMacaron\WindowsFormsApplication1\WindowsFormsApplication1\bin\Release
That's the release folder.
The following error is produced:

There is no bug in VS 2008 in regards to the issue you're experiencing. You somehow corrupted your manifest file or most likely, the config file (macaron.exe.config). The likely cause is that it contains invalid XML and it hasn't been overridden by a default version.
First, try this:
BUILD > Clean Solution; BUILD > Rebuild Solution. In that order.
If that doesn't fix the issue, you need to look into your *.config file and check to make sure that you didn't leave off a closing bracket or have an extra quotation mark in there somewhere. If there is no sensitive information, post your configuration file contents in your original post, so that we may check it for errors.
Last, but not least, if you're still having issues, there could be a possibility of the specified .NET framework incompatibility with the machine or some of the references you're using, as specified in the config file. Since it is specified in the *.config file and it may be off from what you're working with, it could propagate into the error you're seeing. I am not sure if you've created that project on your current machine or if you've imported it from somewhere else, but it maybe that you need to go into your project properties and change the .NET framework version to your desired target version. This will override the supported runtime in the configuration file. The reason you may not be seeing the error in other directories could be due to the fact that you're not copying the configuration file (we don't know, since we don't know everything you're doing).

Related

Which files in bin/Release folder are needed? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
After building the release version for my application, I went to the bin/Release folder and saw a bunch of my project dependencies, such as "Newtonsoft.Json.dll", "System.Memory.dll" and so on.
I have referenced posts like What files are mandatory in release windows form? and saw that these dependencies are needed for my application to run smoothly.
However, I only needed to copy one file - my "main.dll" to the application (I'm creating an add-on for Revit) and it works fine. So, I'm wondering which files could be excluded? This is because my application is still being modified and new dependencies are being added, and I would like to know which files are not needed.
Is there a list of dependencies that have already been included in windows automatically?
In short, you probably need them all and sometimes some. The long version -- it depends. Below is not an exhaustive list but some points to consider:
Whatever is part of the .NET framework that you are using is not normally copied to the output directory
The examples that you listed normally should be copied to the output as they are not part of .NET Framework
You can force a reference to be copied by setting Copy Local to true, which would result in a potentially unnecessary DLL in your output directory
You may have some dependencies in the GAC, which means they might not be copied to the output directory. For example, are you using Infragistics, etc. controls -- do all of your users have them installed on their machines? Probably not and they probably shouldn't, so include them...
The compiler is generally smart about not including things to which you have no actual code references (this can lead to problems if there are dynamic invocations only)

.NET Build events xcopy application settings.settings

I am trying to add these lines to the application's Build Events
xcopy debug.settings settings.settings
In order to acees the debug.settings as Default, but I am getting a exited with code 4 error when compiling. I have read code 4 would probably mean that it cannot find the specified files. But how would I reference debug.settings?
I have this file as part of my application's properties:
I got this idea from a stackoverflow question: .NET different application settings for development and release This would be a followup question based on its answer.
This is likely because xcopy cannot find the source and destination paths for the settings files. Try updating them to the fully qualified path (i.e. C:\SomeFolder\MyProject\debug.settings).
Also, check out the documentation when in doubt (or looking for what error codes mean).
As an aside, if you are simply looking for a way to change values in an app.config or web.config based on your build configuration, take a look at SlowCheetah.

Trying to compile ASPNetWebStack getting 35MSSharedLib1024.snk missing private Key

Have been trying to compile source from https://aspnetwebstack.codeplex.com/
Loaded Runtime.csproj,
added a project to be able to step through MVC source.
Disabled Delay Signing,
then built, and received.
Error 1 Cryptographic failure while signing assembly 'c:...\aspnetwebstack-master\src\System.Web.Mvc\obj\Debug\System.Web.Mvc.dll' -- 'Key file 'c:...\aspnetwebstack-master\src\System.Web.Mvc\35MSSharedLib1024.snk' is missing the private key needed for signing' C:\Files\Projects\aspnetwebstack-master\src\System.Web.Mvc\CSC System.Web.Mvc
(p.s. build.cmd built successfully but with skipstongnames enabled, but the project doesn't build for System.Web.Mvc and ofcourse for its dependencies).
Sorry for the open ended question but, what may I be doing wrong here
ok looks like Disabling Delay Signing was a mistake.
This link helped me through though
http://www.codedistillers.com/?p=53
Tried to reproduce the issue copying the source to another place, and retried the procedure.
Was thinking of recommending not to open Runtime.sln and built it from the IDE before running build.cmd from the Admin privileged command line, but found out that you should be able to build from the IDE without a problem and get your binaries in the aspnetwebstack-master/bin/Debug and can reference them in your project.
All seems to be working fine now. Added this for future reference and if someone else may stumble upon such a problem.
One more thing, if you build your source from build.cmd and your * Build failed * chances are there is a message asking you to postfix Skipskipstrongnames /e to the build command do so and it will succeed.
Some old walkthroughs misdirect by asking you to download Skipstrongnames.exe from the internet with failing links. Not to worry. Once you start the build process, either be it from the IDE or this build.cmd, the Nuget packages will be loaded and the Skipstrongnames.exe will be located in the aspnetwebstack-master/packages/Microsoft.Web.SkipStrongName.1.0.0/tools folder. version may vary overtime but just for reference thought to mention it here.
Hope this helps somebody

Xamarin – Error Fixing “The Aapt task failed unexpectedly”

I am facing issue when i re build or build my droid project. I have updated my Android SDK but issue still is in my solution. Please suggest me how to remove this issue.
I have tried many solution which are on google but issue still come up.
For me, giving 2.1 in Version Number property of the Project Properties gave this error. So after changing it to 2, the project built successfully.
As referring to above mentioned Post by Milen Pavlov i.e :
https://forums.xamarin.com/discussion/39861/latest-update-aapt-task-failed-unexpectedly.
It looks that your Droid CS.Proj containing two references of a same file. So, open it on Notepad and identify the duplicate reference carefully and remove that.
OR
If you have any recent backup of your project then you can Compare Droid CS.Proj with existing Droid CS.Proj to filter new changes and then identify duplicate reference.
I remember Once I faced this problem a few days ago after I'd added an image to the resources folder which its name was shopping_card.png. I renamed the image to shoppingcard.png (removing -) and problem resolved.
In your case also I think something is wrong with resources. Have you ever add a new resource lately? Try to remove them, clean and then rebuild project hope this resolves the issue.
We eventually solved this issue, passing through some other errors that might happen (or not) according to your own environment.
There is this old Android bug https://code.google.com/p/android/issues/detail?id=80808
This implies that Google had the bug in the older Android SDK build-tools versions (and hopefully they fixed it as mentioned in the above URL).
Anyhow, the error message likely explains why; it is likely because your main dex file does not contain necessary multidex support classes.
One possible cause of the problem is your dx.jar might be old and have the issue mentioned above. Assuming you have fairly up-to-date Xamarin.Android, try installling the latest "build-tools" Android SDK component and remove older versions.
Or, instead of removing old SDK build-tools, add AndroidSdkBuildToolsVersion build property to the .csproj file within some active :
<AndroidSdkBuildToolsVersion>23.0.1</AndroidSdkBuildToolsVersion>
In my case this raised other errors that I solved using JDK 1.8
After that I encountered the following Xamarin Bug (The option for multi-dex fails when the path to the Android SDK contains a space
) that can be solved locating the android-sdk in a path without spaces (so for example c:\program files(x86)\android\android-sdk is not a valid location)
You might also see an error due to m2Repository path that can be solved thanks to the info at the following link https://developer.xamarin.com/guides/android/troubleshooting/resolving-library-installation-errors/
Bear in mind that you might need to add/update/remove the Android-sdk packages/version. Here what worked for me.
Items stroke in red are not needed.
It was critical for me to install the obsolete version of the android Support library (23.2.1). (which can coexist with the latest version).
I have also faced the same error:
aapt.exe exit with code -1
That means you have probably used or imported some media or an image, and those image names contain characters that conflicts in XML file (because Xamarin and Android use many XML markup style). Just check out all the items you've imported from outside of your project and correct their names (remove all special characters like -+*/_, and that yet)...
In my case, the solution was to go to Android project's properties and remove Version Number and Package Name values. I don't know why it worked. If someone could explain, it will help future visitors of this question.

Visual studio - getting error "Metadata file 'XYZ' could not be found" after edit continue

I have stumbled into an issue that is really annoying.
When I debug my software, everything runs OK, but if I hit a breakpoint and edit the code, when I try to continue running I get an error:
Metadata file 'XYZ' could not be found
After looking around for a while, I found some a similar issues, but they were all regarding a build failure, which is not my case (this happens only after edit-continue).
What I have tried so far:
My code is compiling and running.
I cleaned the solution and restarted VS.
I made sure that the missing file's project is being build for the configuration I am running (in configuration manager).
I manually built the missing file's project.
Some extra info:
It does not matter what I change, still get the same error (the change is not related to the missing file).
This happens also when I pause and continue (not only breakpoints)
I am running the project using a custom configuration (configuration manager...). When I run it using the default Debug configuration the error does not occur.
Any ideas?
Eventually what solved the issue was:
Clean every project individually (Right click> Clean).
Rebuild every project individually (Right click> Rebuild).
Rebuild the startup project.
I guess for some reason, just cleaning the solution had a different effect than specifically cleaning every project individually.
Edit:
As per #maplemale comment, It seems that sometimes removing and re-adding each reference is also required.
Update 2019:
This question got a lot of traffic in the past, but it seems that since VS 2017 was released, it got much less attention.
So another suggestion would be - Update to a newer version of VS (>= 2017) and among other new features this issue will also be solved
As far as I can tell, this happens when the project dependencies gets messed up for whatever reason (whilst all the inter-project references are still intact). For many cases, it is NOT a code issue. And for those who have more than a few projects, going through them one at a time is NOT acceptable.
It's easy to reset project dependencies -
Select all projects and right click unload
Select all projects and right click reload
Rebuild solution
For those who have an issue in their code or some other issue that's causing this problem you'll obviously have to solve that issue first.
One possible reason could be you have upgraded the some of your projects (in the solution) to higher version e.g. from .NET 4.0 to 4.5 This happened in my case when I opened the solution in VS 2013 (originally created using VS 2010 and .NET 4.0). When I opened in VS 2013 my C++ project got updated to .NET 4.5 and I started to see the problem.
Generally this kind of error comes with human mistakes like if we change the namespace in some improper way, or changing folder names from explorer for current project etc, where compiler is unable to detect sometimes.
I came across the same error, to resolve which I tried few steps. Please follow all the steps :
Clean whole Solution
Right Click on every Project in your solution , Go to Properties and make your Default namespace as well as Default assembly name same as in your code (i.e namespace before class name)
Check Folder names for each project by going through the explorer(Where your project solution is). If not matching with your project names, make it similar (Like step 2) to them.
Remove all your references from each project relevant to another of same solution, and add it again.
In Your Project Solution folder, you will find Visual c# Project file. Right click and open with Notepad. In your initial lines you would find for lines for every project like below:
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "**Client**", "**Client** \ **Client**.csproj", "{4503E259-0E3B-414A-9074-F251684322A5}"
EndProject
Check again Foldernames (I have highlighted in BOLD) and make it similar to what you did in step 2.
Clean the whole solution again
Build The Solution (If doesn't work try building individual after cleaning again)
Make sure all your dependent projects are using the same .Net Framework version. I had the same issue caused by a dependent project using 4.5.1, while all others were using 4.5. Changing the project from 4.5.1 to 4.5 and rebuilding my solution fixed this issue for me.
XYZ couldn't be found because is not built yet....
Right click on the solution and check Project Dependencies, the Project Build Order should also change according to the dependencies that have been set.
The only thing that worked for me was to delete the Solution User Options (.suo) file. Note that, this is a hidden file.
To locate this file, close your Virsual studio and search for .suo from the file explorer within your project.
PS: a new .suo file will be created again when you rebuild your project and hopefully this newly created one wont give you issues.
I hope that helps someone get rid of this anoying error :).
I had this problem for days! I tried all the stuff above, but the problem kept coming back. When this message is shown it can have the meaning of "one or more projects in your solution did not compile cleanly" thus the metadata for the file was never written. But in my case, I didn't see any of the other compiler errors!!! I kept working at trying to compile each solution manually, and only after getting VS2012 to actually reveal some compiler errors I hadn't seen previously, this problem vanished.
I fooled around with build orders, no build orders, referencing debug dlls (which were manually compiled)... NOTHING seemed to work, until I found these errors which did not show up when compiling the entire solution!!!!
Sometimes, it seems, when compiling, that the compiler will exit on some errors... I've seen this in the past where after fixing issues, subsequent compiles show NEW errors. I don't know why it happens and it's somewhat rare for me to have these issues. However, when you do have them like this, it's a real pain in trying to find out what's going on. Good Luck!
Well, my answer is not just the summary of all the solutions, but it offers more than that.
Section (1):
In general solutions:
I had 4 errors of this kind (‘metadata file could not be found’) along with 1 error saying 'Source File Could Not Be Opened (‘Unspecified error ‘)'.
I tried to get rid of ‘metadata file could not be found’ error. For that, I read many posts, blogs etc and found these solutions may be effective (summarizing them over here):
Restart VS and try building again.
Go to 'Solution Explorer'. Right click on Solution. Go to Properties. Go to 'Configuration Manager'. Check if the checkboxes under 'Build' are checked or not. If any or all of them are unchecked, then check them and try building again.
If the above solution(s) do not work, then follow sequence mentioned in step 2 above, and even if all the checkboxes are checked, uncheck them, check again and try to build again.
Build Order and Project Dependencies:
Go to 'Solution Explorer'. Right click on Solution. Go to 'Project Dependencies...'. You will see 2 tabs: 'Dependencies' and 'Build Order'. This build order is the one in which solution builds. Check the project dependencies and the build order to verify if some project (say 'project1') which is dependent on other (say 'project2') is trying to build before that one (project2). This might be the cause for the error.
Check the path of the missing .dll:
Check the path of the missing .dll. If the path contains space or any other invalid path character, remove it and try building again.
If this is the cause, then adjust the build order.
Are you using a database code generation tool like SQLMETAL in your project?
If so, you may be facing a pluralized to unpluralized transition issue.
In my case, I have noted that some old pluralized (*) table names (upon which SQLMETAL adds, by default, an "s" letter at the end) table references to classes generated by SQLMETAL.
Since, I have recently disabled Pluralization of names, after regerating some database related classes, some of them lost their "s" prefix. Therefore, all references to affected table classes became invalid. For this reason, I have several compilation errors like the following:
'xxxx' does not contain a definition for 'TableNames' and no extension method 'TableNames' accepting a first argument of type 'yyyy' could be found (are you missing a using directive or an assembly reference?)
As you know, I takes only on error to prevent an assembly from compiling. And that is the missing assemply is linkable to dependent assemblies, causing the original "Metadata file 'XYZ' could not be found"
After fixing affected class tables references manually to their current names (unpluralized), I was finnaly able to get my project back to life!
(*) If option Visual Studio > Tools menu > Options > Database Tools > O/R Designer > Pluralization of names is enabled, some SQLMETALl code generator will add an "s" letter at the end of some generated table classes, although table has no "s" suffix on target database. For further information, please refer to http://msdn.microsoft.com/en-us/library/bb386987(v=vs.110).aspx
Hope it helps!
I had this error come up. I followed all of the solutions here but nothing worked. I was using Visual Studio 2013 Professional. I couldn't get the individual project rebuilds to work and I finally figured out there was a circular dependency in my references. Visual Studio does a pretty good job normally of warning you if you are adding a reference to something that references back, but for some reason it didn't in this instance. I added a reference to a project that referenced the project I was working on - and it accepted it. VS bug perhaps?
My 5 cents.
This problem started after a solution wide clean.
I managed to get the problem to go away by setting the Active Solution configuration in: Build -> Configuration manager to release. Then build and set it back to debug again. The build succeeded after that.
Close VS, locate and remove the 'packages' folder from outside of visual studio. Restart VS and build -> all dependencies are reinstalled
Visual Studio 2019 Community 16.3.10
I had similar issue with Release build. Debug build was compiling without any issues.
Turns out that the problem was caused by OneDrive. Most likely one could experience similar issues with any backed-up drive or cloud service.
I cleaned everything as per Avi Turner's great answer.
In addition, I manually deleted the \obj\Release -folder from my OneDrive folder and also logged to OneDrive with a browser and deleted the folder there also to prevent OneDrive from loading the cloud version back when compiling.
After that rebuilt and everything worked as should.
this happens because of the difference of names in the folder name and namespace name. If u create a namespace in a certain name , and later you rename it the namespace will have the old name itself. And the compilation will take the old path to find the .dll and .exe file . To avoid this open the .csproj file of each namespace with a text file , and find the old path in the file.
remove this, clean and rebuild the solution. This worked for me. I spent an entire day working on this problem.
I had this and managed to fix it using this SO answer:
Metadata file '.dll' could not be found
I had to uncheck all of the boxes, click Apply, reenable all of the checkboxes and then click apply again, but it fixed the problem.
I just ran into this issue and after an hour of screwing around realized I had added an aspx file to my product that had the same name as one of my Linq-To-Sql classes.
Class and Page where "Queue".
Changed the page to QueueMgr.aspx and everything built just fine.
For a new build, it could be that some dependencies aren't installed. For me it was Crystal Reports.
It happens when one project dll is failing and that is referenced by number of projects. So first fix it and then Build individuals.
I ve had this problem and it has started after importing our solution to TFS as a new project.I came across this topic and found a quick solution with some inspiration from your answers.
All i needed to do is to rebuild the project thats supposedly lost its metadata file and voila , problem solved.
There's also one another silly reason which you should check with patience... as it occurred to me after wasting 4hours searching for answers:
The story to me was that I accidentally changed a small line of code among thousands of c# class files and then trying to rebuild the solution. As you could imagine, I ended up with 40+ meta data file missing errors and with 1 compilation error among them -- which I didn't check carefully, purely thinking all errors were the same!
after 4 hours searching and then accidentally double checking my error list, I found that silly code error, fixed it, compiled, and then error disappeared.
Not a good answer to your problem, but do hope my case wasn't same to yours.
I had the same problem. In my case I had by mistake I had set all the projects apart from the project with the main method as console application.
To resolve I went to every project other than the one with main function and right click> properites > output type > class library
it was happened to me because I've a strange clash in the namespaces:
I had
AssemblyA
with namespace
AssemblyA.ParentNamespace
witch defines ClassA
and in the same assembly another namespace with name
AssemblyA.ParentNamespace.ChildNamespace
witch defines a different ClassA (but with the same name)
I had then in AssemblyA.ParentNamespace IInterfaceB witch had a method that in the beginning returns IEnumerable and a ClassB witch implements IInterfaceB
I had later modified the method in ClassB to return IEnumerable but I've forgot to update the IInterfaceB definition, so the method there was still returning IEnumerable
the fun fact was that the solution still complile if I did a rebuild all, but the tests witch refers AssemblyA didsn't work and returns the "Metadata file could not be found"error.
updating InterfaceB to correctly return IEnumerable as its implementor ClassB did solved the problem, unfortunately the error message was vague and also the fact that the compilation worked makes me suppose that maybe there is something to fix in the compiler
A coworker was running into this problem and the cause was eluding us. Eventually we realized that the project directory (and therefore the path to the NuGet packages) contained %20 (thanks, some Git gui tool which shall not be named) and the error messages showed that the compiler was looking for an very similar-looking path but one which had to %20, rather a space. Apparently something in the build system somewhere performs HTML-decoding on local filesystem paths.
Renamed the working copy directory and everything started working.
I had this issue too.
It started after I did a little folder tidying in my project.
I then tried to compile and got many duplicate class errors. (despite them not being duplicated. I think the linking was just out of wack)
Upon checking these, the errors would all disappear leaving only the "Metadata file ...debug\application.exe could not be found" error.
I solved this by looking in the build output window to find which classes were duplicated.
I would then right click the class name and "go to definition".
there will be two definitions to select from, open them both, the second definition will seem to open the same file again, however the second one will identify as the error source(red underline).
Delete all the code out of the file and save(This will not effect your actual file).
This should now compile correctly.
Ensure that there are no spaces in the path to your project...
I am using Windows 10 with Visual Studio Community 2019 and I was cloning a multi project solution as it was from a GIT repo. I was having this error with all other dependencies in the solution along with a E_POINTER error. Its path, inherited from GIT, had spaces like C:/repos/MY PROJECT NAME/ ...
I deleted it, cloned it again and make sure that its path contained no spaces like C:/repos/MY_PROJECT_NAME/ ...
That fixed my problem.
I had same issue too.
In my case, I recently add an internal class to somewhere in project. One of the dependencies in solution has same class name and both of them are added correctly to references.
I changed my last activity and rebuild, it works.
Be sure that your compiler messages are valid. In my case I catch reference error from there, not listed as an error in Error List.

Categories

Resources