Error 1 error MSB4018: The "MIDL" task failed unexpectedly.
System.TypeInitializationException: The type initializer for
'Microsoft.Build.Utilities.FileTracker' threw an exception. --->
System.IO.FileNotFoundException: The system cannot find the file
specified. (Exception from HRESULT: 0x80070002) at
System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32
errorCode, IntPtr errorInfo) at
System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32
errorCode) at
Microsoft.Build.Shared.NativeMethodsShared.ThrowExceptionForErrorCode(Int32
errorCode) at
Microsoft.Build.Shared.NativeMethodsShared.GetShortFilePath(String
path) at Microsoft.Build.Utilities.FileTracker..cctor() --- End of
inner exception stack trace --- at
Microsoft.Build.CPPTasks.TrackedVCToolTask.ComputeOutOfDateSources()
at Microsoft.Build.CPPTasks.TrackedVCToolTask.SkipTaskExecution() at
Microsoft.Build.Utilities.ToolTask.Execute() at
Microsoft.Build.CPPTasks.TrackedVCToolTask.Execute() at
Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at
Microsoft.Build.BackEnd.TaskBuilder.d__20.MoveNext()
C:\Program Files
(x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets 1179
Is this problem affecting all projects?
I had similar problem when porting code from older version of VS. Form my experience the most errors are generated because paths. I do not remember details but using output paths explicitly (done in older versions) creates problem since project conversion mechanism tries to use macros and as a result in empty, wrongly formatted paths.
My advice is to verify all settings pertaining to output. Make sure OutputPath, TargetDir and others are set properly. Try changing settings and use to inherit from parent.
Create empty project of the same type and compare properties of both.
Related
I'm having trouble debugging Xunit unittests in .NET6 running on Ubuntu 20.04 in VSCode (1.66.2). These run in VisualStudio and VSCode in Windows. I can run (not debug) the tests in Linux from the CLI or the .NET Core Test Explorer extension.
If I try to debug the unittest with the context menu or the little magic command attribute that is placed above the unittest method declaration, I get an error:
Failed to start debugger:
"System.InvalidOperationException: The debugger could not be started
at OmniSharp.DotNetTest.Services.DebugTestService.Handle
(OmniSharp.DotNetTest.Models.DebugTestGetStartInfoRequest request) [0x00050] in <9d87b466e5a04dffb95becc0b4dfd560>:0
at OmniSharp.Endpoint.Exports.RequestHandlerExportHandler`2[TRequest,TResponse].Handle (TRequest request) [0x00000] in <3d93fabea6954f4ba147450b0cf4332a>:0
at OmniSharp.Endpoint.EndpointHandler`2[TRequest,TResponse].GetFirstNotEmptyResponseFromHandlers (OmniSharp.Endpoint.Exports.ExportHandler`2[TRequest,TResponse][] handlers, TRequest request) [0x00022] in <3d93fabea6954f4ba147450b0cf4332a>:0
at OmniSharp.Endpoint.EndpointHandler`2[TRequest,TResponse].HandleRequestForLanguage (System.String language, TRequest request, OmniSharp.Protocol.RequestPacket packet) [0x00163] in <3d93fabea6954f4ba147450b0cf4332a>:0
at OmniSharp.Endpoint.EndpointHandler`2[TRequest,TResponse].Process (OmniSharp.Protocol.RequestPacket packet, OmniSharp.Endpoint.LanguageModel model, Newtonsoft.Json.Linq.JToken requestObject) [0x0024b] in <3d93fabea6954f4ba147450b0cf4332a>:0
at OmniSharp.Stdio.Host.HandleRequest (System.String json, Microsoft.Extensions.Logging.ILogger logger) [0x000f3] in <2584067dfcea42a69c19a025cfbc4799>:0 "
I also see this in the OUTPUT pane:
/usr/share/dotnet/sdk/6.0.202/Microsoft.Common.CurrentVersion.targets(4650,5): error MSB3883: Unexpected exception: [/home/danielp/Source/Experiments/LibAndTest/Library/Library.csproj]
/usr/share/dotnet/sdk/6.0.202/Microsoft.Common.CurrentVersion.targets(4650,5): error : DirectoryNotFoundException: Could not find a part of the path '/home/danielp/Source/Experiments/LibAndTest/Library/bin/Debug/net6.0/ref/Library.dll'. [/home/danielp/Source/Experiments/LibAndTest/Library/Library.csproj]
/usr/share/dotnet/sdk/6.0.202/Microsoft.Common.CurrentVersion.targets(4650,5): error : at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter) [/home/danielp/Source/Experiments/LibAndTest/Library/Library.csproj]
/usr/share/dotnet/sdk/6.0.202/Microsoft.Common.CurrentVersion.targets(4650,5): error : at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode) [/home/danielp/Source/Experiments/LibAndTest/Library/Library.csproj]
/usr/share/dotnet/sdk/6.0.202/Microsoft.Common.CurrentVersion.targets(4650,5): error : at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize) [/home/danielp/Source/Experiments/LibAndTest/Library/Library.csproj]
/usr/share/dotnet/sdk/6.0.202/Microsoft.Common.CurrentVersion.targets(4650,5): error : at System.IO.FileSystem.CopyFile(String sourceFullPath, String destFullPath, Boolean overwrite) [/home/danielp/Source/Experiments/LibAndTest/Library/Library.csproj]
/usr/share/dotnet/sdk/6.0.202/Microsoft.Common.CurrentVersion.targets(4650,5): error : at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite) [/home/danielp/Source/Experiments/LibAndTest/Library/Library.csproj]
/usr/share/dotnet/sdk/6.0.202/Microsoft.Common.CurrentVersion.targets(4650,5): error : at Microsoft.CodeAnalysis.BuildTasks.CopyRefAssembly.Copy() [/home/danielp/Source/Experiments/LibAndTest/Library/Library.csproj]
/usr/share/dotnet/sdk/6.0.202/Microsoft.Common.CurrentVersion.targets(4650,5): error : [/home/danielp/Source/Experiments/LibAndTest/Library/Library.csproj]
What I find interesting here is that it keeps looking for referenced dlls in ...Debug/net6.0/ref/Library.dll' and there is no build output binary placed there much less a folder called ref.
For now, I can debug w/ a console app, but it sure seems strange that this works so well in Windows but not Linux. However, now that I say that out loud: it seems like it shouldn't be that surprising.
Lastly, I did try debugging mstest unittests w/ the same results.
I figured it out! But only because I found this other answered question:
Cannot Run or Debug C# tests with CodeLens in VSCode
Because I'm running .NET 6, the Omnisharp extension needed a settings change:
Open your VSCode extensions w/ the icon on the left
Search for Omnisharp in the text box
Click the gear icon and choose Extension Settings from the resulting context menu
Up top in the search bar that is revealed in the settings page, append (w/ a space) modern so that the search bar contains #ext:ms-dotnettools.csharp modern
You will see a checkbox labeled Omnisharp: Use Modern Net.
Make sure this is checked.
I had to restart VSCode and allow the extension to do a download
After that it works.
I get the below exception when debugging an xunit test using .net MVC 5, .net framework version 4.6.2 and visual studio 2019.
**
System.IO.FileNotFoundException HResult=0x80070002 Message=Could
not find file 'Could not find file
'..\bin\Debug\TestProj.UnitTests.xunit.runner.json'. Source=mscorlib
StackTrace: at System.IO.__Error.WinIOError(Int32 errorCode, String
maybeFullPath) This exception was originally thrown at this call
stack: System.IO.__Error.WinIOError(int, string)
**
Please see the below images.
for me adding this file was all it took `{projectname}.
and in the file content look like this
{
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json"
}
also don't forget to set the file to copy on build.
based on documentation found here
I am getting a "Could not load file or assembly 'Box.V2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ddda8fe64dde1ac3' or one of its dependencies. The system cannot find the file specified" error in Azure Functions. Any ideas on what the problem might be?
I am using the package.json file to have Azure Functions pull in the references and hook them all up as described in the docs.
When you upload a project.json file, the runtime gets the packages and automatically adds references to the package assemblies. You don't need to add #r "AssemblyName" directives. Just add the required using statements to your run.csx file to use the types defined in the NuGet packages.
https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-csharp
My package.json file:
{
"frameworks": {
"net46":{
"dependencies": {
"BouncyCastle": "1.8.1",
"BouncyCastle-PCL": "1.0.0.6",
"Box.V2": "2.14.0",
"Box.V2.JWTAuth": "1.2.0",
"Microsoft.Bcl": "1.1.10",
"Microsoft.Bcl.Async": "1.0.168",
"Microsoft.Bcl.Build": "1.0.14",
"Microsoft.Net.Http": "2.2.29",
"Newtonsoft.Json": "6.0.2",
"Nito.AsyncEx": "2.1.3",
"System.IdentityModel.Tokens.Jwt": "4.0.2.206221351"
}
}
}
}
run.csx using statements:
using global::Box.V2;
using global::Box.V2.Config;
using global::Box.V2.Exceptions;
using global::Box.V2.JWTAuth;
using global::Box.V2.Models;
Full Exception:
Microsoft.Azure.WebJobs.Host.FunctionInvocationException : Exception while executing function: Functions.GetTelogisFormInstancePdf ---> System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException : Could not load file or assembly 'Box.V2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ddda8fe64dde1ac3' or one of its dependencies. The system cannot find the file specified.
at Submission#0.Run(HttpRequestMessage req,TraceWriter log) at : 84
End of inner exception
at System.RuntimeMethodHandle.InvokeMethod(Object target,Object[] arguments,Signature sig,Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj,Object[] parameters,Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj,BindingFlags invokeAttr,Binder binder,Object[] parameters,CultureInfo culture)
at async Microsoft.Azure.WebJobs.Script.Description.DotNetFunctionInvoker.InvokeCore(Object[] parameters,FunctionInvocationContext context)
at async Microsoft.Azure.WebJobs.Script.Description.FunctionInvokerBase.Invoke(Object[] parameters)
at async Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker`1.InvokeAsync[TReflected](Object[] arguments)
at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.InvokeAsync(IFunctionInvoker invoker,Object[] invokeParameters,CancellationTokenSource timeoutTokenSource,CancellationTokenSource functionCancellationTokenSource,Boolean throwOnTimeout,TimeSpan timerInterval,IFunctionInstance instance)
at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithWatchersAsync(IFunctionInstance instance,IReadOnlyDictionary`2 parameters,TraceWriter traceWriter,CancellationTokenSource functionCancellationTokenSource)
at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??…
The error is clearly stating that it can't find the assembly:
System.IO.FileNotFoundException : Could not load file or assembly 'Box.V2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ddda8fe64dde1ac3' or one of its dependencies. The system cannot find the file specified.
And while you show in your .csx that you have using statements to include the namespaces, no where do you show that you actually reference the external assemblies
As described in the above linked documentation:
If you need to reference a private assembly, you can upload the assembly file into a bin folder relative to your function and reference it by using the file name (e.g. #r "MyAssembly.dll").
Make sure you get the path correct; I had to ensure the bin folder was within my path where the function was - the shared assembly approach didn't work for me.
I also suggest that perhaps an easier approach than dealing with csx and referencing assemblies is to ditch csx all together and use pre compiled functions as described in this blog post. Then you get full compile time resolution of assemblies and proper intellisense that you just don't get with the CSX files.
This error is misleading and I had to end up overriding BoxJWTAuth in order to make it work. The details of this error can be found here: https://github.com/box/box-windows-sdk-v2/issues/297
I have followed this tutorial on getting angular and ASP.NET Core running together. The initial build worked fine but after updating angular packages I am receiving the following error on startup of the application(I also had to reinstall nodejs in the process, not sure if this is related):
The error is on the following line:
app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions {
HotModuleReplacement = true
});
The error itself does not provide me with any usefull information to track down the issue.
I get a:
System.AggregateException => Count = error CS0103: The name
'InnerExceptionCount' does not exist in the current context
Under InnerExceptions it lists the following error:
System.ComponentModel.Win32Exception: The system cannot find the file
specified at System.Diagnostics.Process.StartCore(ProcessStartInfo
startInfo) at System.Diagnostics.Process.Start() at
System.Diagnostics.Process.Start(ProcessStartInfo startInfo) at
Microsoft.AspNetCore.NodeServices.HostingModels.OutOfProcessNodeInstance.LaunchNodeProcess(ProcessStartInfo
startInfo) at
Microsoft.AspNetCore.NodeServices.HostingModels.OutOfProcessNodeInstance..ctor(String
entryPointScript, String projectPath, String[] watchFileExtensions,
String commandLineArguments, ILogger nodeOutputLogger, IDictionary2
environmentVars, Int32 invocationTimeoutMilliseconds, Boolean
launchWithDebugging, Int32 debuggingPort) at
Microsoft.AspNetCore.NodeServices.HostingModels.HttpNodeInstance..ctor(String
projectPath, String[] watchFileExtensions, ILogger
nodeInstanceOutputLogger, IDictionary2 environmentVars, Int32
invocationTimeoutMilliseconds, Boolean launchWithDebugging, Int32
debuggingPort, Int32 port) at
Microsoft.AspNetCore.NodeServices.NodeServicesFactory.CreateNodeInstance(NodeServicesOptions
options) at
Microsoft.AspNetCore.NodeServices.NodeServicesFactory.<>c__DisplayClass0_0.b__0()
at
Microsoft.AspNetCore.NodeServices.NodeServicesImpl.CreateNewNodeInstance()
at
Microsoft.AspNetCore.NodeServices.NodeServicesImpl.GetOrCreateCurrentNodeInstance()
at
Microsoft.AspNetCore.NodeServices.NodeServicesImpl.d__10`1.MoveNext()}
If someone can point me in the direction to get more information from the Error would be helpful.
It looks like it is unable to find node.exe. I saw the same error after installing Node for the first time. It was because installing Node modified the system Path and the new Path wasn't getting picked up by IIS. I had to reboot my server and it was then able to find the node exe.
Check if you have the latest NPM installed. This solved my problem.
I have tried to add the LiveTile plugin (found here) to my clean Cordova 3.3 project. But I can't seem to get it to work. It works with the instruction from the link but that uses Cordova 2.0.0.
I get the following printout when I try to add a new Tile:
An exception of type 'System.InvalidCastException' occurred in System.ServiceModel.Web.ni.dll and wasn't handled before a managed/native boundary
A first chance exception of type 'System.InvalidCastException' occurred in System.ServiceModel.Web.ni.dll
An exception of type 'System.InvalidCastException' occurred in System.ServiceModel.Web.ni.dll and wasn't handled before a managed/native boundary
Unable to cast object of type 'System.Collections.Generic.List`1[System.Object]' to type 'System.Collections.Generic.Dictionary`2[System.String,System.Object]'.
Failed to deserialize Cordova.Extension.Commands.LiveTiles+LiveTilesOptions with JSON value :: ["System.Collections.Generic.Dictionary`2[System.String,System.Object]","LiveTiles963855178"]
A first chance exception of type 'System.NullReferenceException' occurred in CordovaWP8_2.9.14.DLL
An exception of type 'System.NullReferenceException' occurred in CordovaWP8_2.9.14.DLL but was not handled in user code
A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.ni.dll
An exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.ni.dll and wasn't handled before a managed/native boundary
ERROR: Exception in ProcessCommand :: Exception has been thrown by the target of an invocation.
ERROR: failed to InvokeMethodNamed :: createSecondaryTile on Object :: LiveTiles
The thread 0xbac has exited with code 259 (0x103).
Error occurred: Invalid action
Are plugins added differently with this new version of Cordova or is the LiveTile plugin simply not compatible anymore?
This might have been a dumb question, but since the documentation is so poor it is hard to call any question dumb.
I have however manage to solve this now, and in the off chance that someone else runs in to the same problem I'll try to explain what I did.
First I found this implementation of the LiveTiles plugin which seemed to be more recent then the one in the question. Instead of creating a new project through Visual Studio I used the CLI.
phonegap create hello com.example.hello HelloWorld
Then I used plugman to install the plugin according to the link above.
plugman install --project . --platform wp8 --plugin com.risingj.cordova.livetiles
Now I looked through my files to see what had happened.
config.xml - some addition
<?xml version='1.0' encoding='utf-8'?>
<widget>
<access origin="*" />
<feature name="LiveTiles">
<param name="wp-package" value="LiveTiles" />
</feature>
</widget>
a new file was generated: cordova_plugins.js in the www-folder with the following content:
cordova.define('cordova/plugin_list', function(require, exports, module) {
module.exports = [
{
"file": "plugins/livetiles.js",
"id": "com.risingj.cordova.livetiles.livetiles",
"clobbers": [
"LiveTiles"
]
}
];
module.exports.metadata =
// TOP OF METADATA
{
"com.risingj.cordova.livetiles": "0.1.0"
}
// BOTTOM OF METADATA
});
I added these files to a Cordova Visual Studio-project and it worked! So I guess if a new plugin is added this is what is needed.
You need to do this :
cordova plugin add path/to/your/plugin
It will do all the stuff.