System.ArgumentException: 'The path must be absolute. (Parameter 'root')' - c#

One day after pulling commits from upstream and run the C# solution (projects) I got this error message in the title. The compilation was successful completely but at run time I got this error see attachment.

The solution is to clean your projects/solution including docker-compose project. If after doing all this and it still does not work, you will have to into your package-lock.json and ensure that the changes you made before this error happens reflected and up to date. In my case specifically I changed the project folder name and that was not updated in package-lock.json in directives "name":
{
"name": "NameChanged",
"lockfileVersion": 2,
"requires": true,
"packages": {
That is it!
(the clean and rebuild should take care of it).

Related

How to fix An "error occured while writing the output file: CSC File, Line 1"

My solution will not build anymore and gives the error "An error occured while writing the output file: System.NullReferenceException: Object reference not set to an instance of an object." The File stated is CSC and line 1.
It happend after I added some more classes, but when I try to rollback to earlier version it still has the same build problem. Some classes uses Newtonsoft.Json, but that worked in previous builds.
CSC errors could be anything that could be wrong with your proj file. Start with checking if your target files and all other class files that are referred in the proj file exists.
It could also happen that your VS is corrupted. If the project works fine for others, try running a repair.
If you by any chance maintained a history then do a quick comparison which could isolate the issue.
Unfortunately, due to the fact that CSC errors are uncommon, they have very little detail to it. However, you could enable diagnostics in output and try building to narrow down your problem

Inheriting IContainerAcessor on global.asax causes Parser Error

I have started to work on a ASP.NET MVC Unity web project that is building and running successfully for my peers, however when I attempt to run the project I get the following Parser Error that references line 1 of my Global.asax file:
"Parser Error Message: Signature of the body and declaration in a
method implementation do not match."
This error can be avoided by removing the reference to
IContainerAccessor and the inherited container property from
Global.asax.cs.
When I try to debug the problem by putting a breakpoint at the beginning of Application_Start, the build will still work but I receive the error page without hitting the breakpoint.
This problem persists even after getting exactly what is working for others via source control. I am not sure what else I can try, any help is greatly appreciated.
Two reasons for that error message:
1 Your local web server is running different code than what you're
actually working on:
to fix that try this:
stop debugging.
stop your local web server
clean and rebuild
You might need to re-create the Virtual Directory.
2 Your local project is pointing to a a dll library version that is different than the one in the source control

File and Line Numbers for Errors are not Displaying in the Error List Unless the File Is Open

I have a solution where the file name and line number of the error isn't displaying in the Error List, unless I have the file open.
I have another solution where just three errors show up when I build the solution, and they do display the line number and file. If I open the file with the error, another 3 errors pop up, but when I close the file, all the errors disappear until I rebuild again.
The only issue I've seen from googling is that the path is too long or too weird, but I don't think this is an issue. Path is C:\TFS\Apps\Rel_2013.7.1\S3\CrmSvcUtil Extensions for the solution that is partially working and C:\TFS\Apps\Rel_2013.7.1\S3 for the one that doesn't work at all.
Edit 1
Just to make it clear what I'm seeing: I have multiple projects in my solution but one of them doesn't show the file or line number of the error unless the file is open.
In this screen shot I've added two dumb errors, each in a different project, and have built the solution. The Test Project displays the file and line number as expected. The Common project isn't displaying the file or line number error even though it should and does when I actually open the file with the error in it. The Warning isn't displaying the file because it is a project level warning, not a file level warning, this makes sense.
When I open the file with the error the file name and the line number do show up, but on a different error:
If I change the int to a string, only the line numbered error is removed. I actually have to build in order for the error to be removed.
I had the same issue on projects that are using legacy Workflow framework V3. Interesting to note, that if project has only compiler warnings, the file and line are shown correctly, but error causing all warnings and errors refer to file C:\Windows\Microsoft.NET\Framework\v4.0.30319\Workflow.Targets(121,5):
The nasty workaround that I found is
Unload the project
Comment out at the bottom of the .csproj file the line
<Import Project="$(MSBuildToolsPath)\Workflow.Targets" />
Reload the project and compile it. Compiler errors will be shown with correct file name and line numbers.
Fix compiler errors
Again unload the project, restore Workflow.Targets import and reload the project.
The similar solution was reported to MS https://connect.microsoft.com/VisualStudio/feedback/details/797056/state-machine-workflow-projects-using-vs-2012
If you forget to restore Workflow.Targets import, there will be run-time errors like
System.Workflow.ComponentModel.Compiler.WorkflowValidationFailedException: The workflow failed validation.
at System.Workflow.Runtime.WorkflowDefinitionDispenser.ValidateDefinition(Activity root, Boolean isNewType, ITypeProvider typeProvider)
at System.Workflow.Runtime.WorkflowDefinitionDispenser.LoadRootActivity
Certain errors such as schema errors are reported but don't affect the final build. Depending on the file you may/may not see errors unless the file is open. Here are some things to try
Build in debug/release mode and see if that changes things for either build.
Change the MSBuild Project Build Output Verbosity (Tools-> Projects & Solutions -> Build and Run) to see if that has an effect. I surmise that will only add to the output but not affect on the Error List Window.
Does this happen in VS2013? That might provide a clue.
It is not unusual there to be differences between output builds and intellisense errors as reported.
Sounds to me like you are just looking at errors that are generated by the IntelliSense parser. Which only looks at open files. When you close the file then those IS errors will be removed from the list again. Seeing the error list change after you've built and open a file is similarly explained, the IS parser takes over again.
This is all by design, get ahead by just fixing the errors.
Michaels solution didn't work for us in May, 2018.
Visual Studio 2017 + .NET 4.7.2, and C# 7.2, old Workflow service.
It was inline variable declerations added:
int.TryParse(s, out int queueId);
Went back to pre-defining variables and it compiled successfully.
int queueId = 0;
int.TryParse(s, out queueId);
I would ascertain Microsoft has a bug.
Sample Errors:
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Workflow.targets(121,5): error : Invalid expression term 'int'
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Workflow.targets(121,5): error : ; expected
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Workflow.targets(121,5): error : Invalid expression term ')'

'Object reference not set to an instance of an object' at compile time

I made a game and released it. I want to make a Lite version of the game so I decided to make a 2nd project in my solution named 'myGameLite'.
It's a Xaml/Monogame project like the original one.
I deleted all the *.cs and *.xaml files of the Lite project and added all the files of the original project as a link. Now when I try to build the Lite project, I get the next error:
Error 1 Object reference not set to an instance of an
object. RockTheBlockLite.WinRT
Definitely looks like a NullReferenceException but I've never seen it in compile time.
I doublechecked all values in my project properties and in the appxmanifest but I can't find anything wrong in there.
The original project still compiles.
Anyone got an idea how I can get this solved?
I've fixed it. It was kinda hard for anyone to figure out without seeing the actual solution.
The App.xaml was also added as link but it wasn't set up as ApplicationDefinition . So the whole project didn't have an ApplicationDefinition which is why this occured.
I guess a better error would've been: 'No application definition found' instead of showing a NullReferenceException but at least it's solved and it's on SO now in case others get this problem too :)

Error "object is currently in use elsewhere" TFS GetLatest

We have our code available in TFS. When we take code in one machine (in a different location) it throws an error "object is currently in use elsewhere". Also one of the C# files is not getting downloaded. When we try to build it says "Source file 'filename' could not be opened ('Unspecified error')
This is not reproduced in other locations. Any idea what could be the issue?
Note: It is an asp.net website. We have used enterprise library. Also there is a chart control.
Note: We are using VS 2010.
I have read the following. But thge difference here is that the error is coming as and when we are taking latest from TFS. Is the TFS doing a build while taking latest itself?
InvalidOperationException - object is currently in use elsewhere - red cross
also
Error : Object is currently in use elsewhere.
If project solution name or some files have unique characters in names or some variable names in code other than basic latin letters, then sometimes moving the project would give these errors.
The first error seems like you are using some unmanaged code in your code base, so you would need to get the code in here which might help in why this is caused.
The second case is of the file being deleted from the repository and that .proj file on your machine has not been updated, so it complains of the missing file, you may have to remove it from your project for it to work. one of the file is not getting downloaded coz its not there in the repository at all

Categories

Resources