Task Scheduler with .dll - c#

net core 2.0 console app on a schedule only problem is i have a .dll file - I have followed resources which say to put the 'Start-in' option to the path of project and this hasn't worked - however when I navigate to the folder with the dll and run dotnet name.dll in cmd it executes the console app fine.
Here is the error i'm getting
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

rsine provided the answer in his question Scheduling multiple .net core console apps.
Example of 'New Action' form
Program/Script dotnet
Add Arguments program.dll arg1
Start In E:\User\ProgramFolder

Related

Could not load file or assembly 'Microsoft.AspNetCore.Http.Extensions, Version=3.1.0.0 in windows 10 machine

I am trying to run my Dotnet-Core web Api project in windows 10 machine. But I am facing runtime error. I 'm not allowed to change the Application nuget version too
>fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HMLLR56JLU26", Request id "0HMLLR56JLU26:0000000B": An unhandled exception was thrown by the application.
System.BadImageFormatException: Could not load file or assembly 'Microsoft.AspNetCore.Http.Extensions, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. Format of the executable (.exe) or library (.dll) is invalid.
File name: 'Microsoft.AspNetCore.Http.Extensions, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
at Microsoft.AspNetCore.StaticFiles.StaticFileContext.get_RequestHeaders
at Microsoft.AspNetCore.StaticFiles.StaticFileContext.ComputeIfMatch()
at Microsoft.AspNetCore.StaticFiles.StaticFileContext.ComprehendRequestHeaders()
at Microsoft.AspNetCore.StaticFiles.StaticFileContext.ServeStaticFile(HttpContext context, RequestDelegate next)
The answer here lies in - BadImageFormatException. One of these
Your app is compiled for one architecture (x64 or x86) but your Web Server pool runs different one
One of the 3rd party DLLs is of incompatible architecture (your case)
One of your DLLs is of incompatible architecture.
DLL is compiled for the wrong platform. e.g. running DLL compiled for .net4.8 in the .netcore (your case)

msbuild works whereas dotnet build fails

I have some libraries built on C# .NET Core 3.1.
When I execute the command
dotnet build "core\core.csproj"
I get the following error
C:\Users\christos.nuget\packages\visual-stylecop.msbuild\4.7.59\build\Visual-StyleCop.MSBuild.Targets(107,5): error MSB4062: The "StyleCopTask" task could not be loaded from the
assembly
C:\Users\christos.nuget\packages\visual-stylecop.msbuild\4.7.59\build..\tools\StyleCop.dll.
Could not load file or assembly 'System.Windows.Forms,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
The system cannot find the file specified. Confirm that the
declaration is correct, that the assembly and all its
dependencies are available, and that the task contains a public class
that implements Microsoft.Build.Framework.ITask.
But when I use msbuild
& 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MSBuild.exe' "core\core.csproj"
it finishes without problems.
Any idea why?
thanks in advance for any help

Could not load file or assembly 'Microsoft.NET.HostModel' after .NET Core upgrade

My .NET Core was recently upgraded from 3.1.402 to 3.1.403; after this update, when i try to run my project with dotnet run command, i'm receiving this message:
[MSBuild solution compiling events] - Error at file
'/usr/share/dotnet/sdk/3.1.403/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets',
from project '{my csproj file path}';
error associated with lines 424-0; Sender: MSBuild. Code error:
MSB4018; message: 'The "CreateAppHost" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load file or assembly
'Microsoft.NET.HostModel, Version=3.1.6.0, Culture=neutral,
PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
I'm using Ubuntu 20.04; before the SDK upgrade the project was working fine. Is it some kind of bug from the new version of the .NET Core SDK?

FileNotFound Exception when referencing LinqPad.exe

I am trying to use LinqPad's dump feature (https://stackoverflow.com/a/9437947/3375305) from within Visual Studio. (.netCore 1.1 Console App).
I have added a reference to LinqPad.exe, but whenever I try and run the program, a File Not Found exception is thrown.
System.IO.FileNotFoundException: 'Could not load file or assembly
'LINQPad, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=21353812cd2a2db5'. The system cannot find the file
specified.'
I have tried LinqPad 5.10, 5.10 AnyCPU, 5.21 AnyCPU (Beta)

Could not load file or assembly System, Version=2.0.5.0 in .NET 4 MVC 4 application

Been searching for ages, can't find anything helpful. Here is the exception I'm getting:
Could not load file or assembly 'System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
Exception Details: System.IO.FileLoadException: Could not load file or assembly 'System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
Stack Trace:
[FileLoadException: Could not load file or assembly 'System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)]
StructureMap.Graph.PluginGraph..ctor() in c:\BuildAgent\work\996e173a8ceccdca\src\StructureMap\Graph\PluginGraph.cs:41
StructureMap.PluginGraphBuilder..ctor() in c:\BuildAgent\work\996e173a8ceccdca\src\StructureMap\PluginGraphBuilder.cs:22
StructureMap.InitializationExpression..ctor() in c:\BuildAgent\work\996e173a8ceccdca\src\StructureMap\InitializationExpression.cs:22
StructureMap.ObjectFactory.Initialize(Action`1 action) in c:\BuildAgent\work\996e173a8ceccdca\src\StructureMap\ObjectFactory.cs:47
...
This applications works fine on the test server but is throwing this exception on the production server. As you can see, the StructureMap code is what is causing the exception.
I had to convert this app to .NET 4 from 4.5 because 4.5 wasn't installed on the production server. After the conversion, the app still works fine on my local machine and the test server.
I have already set the Copy Local to True for the System assembly, but since the referenced version is 4.0.0.0 and not 2.0.5.0, I this made no difference.
Let me know if any more info is needed. Any help you may be able to provide is appreciated.
Make sure your .NET framework is patched. Microsoft released patches to .NET to allow Portable Class Libraries to properly find the appropriate runtime (KB2468871). If you are seeing the above exception (or something like it), it means you're missing the latest .NET framework patches.
Edit the web.config file to remove the reference, which is not required for normal operation:
1 - Open the web.config file in the root of your site
2 - Find the following line and comment it out():xxxxx-is your assembly name.
<add assembly="xxxxx", Version=2.0.5.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
3 - Save and close the web.config file and try again
I found that it was the "await" and "async" that where giving me trouble.
I had Windows XP SP3 with only .NET 4.0, but had to update it to .NET 4.0.3 using KB2600211 - this wasn't updated automatically through Windows Update when .NET 4.0.3 came out because the computer is off-grid.
This is the link to the update:
https://www.microsoft.com/en-us/download/details.aspx?id=29053
I just want to share another solution from here that solved the problem on my development machine: installing Silverlight 5 SDK (only 11.2MB at the time of writing this post) was enough to make everything working.
Install Microsoft® Silverlight® 5 SDK from the following link. It resolves and works fine for me.
SDK download
Starting from a machine configuration that only had VS2017 and Silverlight 5 SDK on it, I installed VS2015 on top of that. This is when I started getting the System.Core and System.Windows problems.
When I uninstalled VS2015 and re-installed Silverlight 5 SDK, these problems went away.

Categories

Resources