Running Windows Update through wuapi.dll - c#

I've added a reference to Interop.WUApiLib in my project, a console application. I'm trying to test out silently running updates on virtual machines but its not going so well. When I try to run the console app, it immediately crashed with the following error:
Unhandled Exception: System.IO.FileNotfoundEXception: Could not load file or assembly 'Interop.WUApiLib, Version=2.0.0.0, Culture=nuetral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. File name: 'Iterop.WUApiLib, Version=2.0.0.0, PublicKeyToken=null' at WindowsUpdateconsoleTest.Program.Main(String[] args)
I've checked the version on wuaueng1.dll and its 5.3.3790.5512, so WUA should be installed. I'm developing on Windows 7, the virtual machines are on Windows XP Service Pack 3. My local machine(which appears to run it fine is on a later version of wuapi.dll). Is that the issue? Or is something else going on?
I would really like to not have to call powershell scripts on these machines if I can avoid it.

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)

Task Scheduler with .dll

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

Unhandled exception in mono while running NancyFx

I'm running Ubuntu 12.04 and I have the mono-runtime package installed. On my windows machine my NancyFx self hosted application compiles fine with 1 warning but when I try to run it on my VPS I get the following error:
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or
assembly 'System.Core, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' or one
of its dependencies.
File name: 'System.Core, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089'
[ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileNotFoundException: Could not load
file or assembly 'System.Core, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' or one of its dependencies.
File name: 'System.Core, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089'
Any ideas on how I can fix this?
I ran across the same problem when trying to run a Mono app (compiled in Xamarin Studio on my Windows machine) on an Ubuntu 14.04 Docker virtual. I did the same thing as you and installed mono-runtime, and after an hour or two of searching, was able to get it to work after installing mono-complete. However, that also brings down a few hundred MB of additional stuff. Finally I found the package that did the trick: libmono-system-core4.0-cil (see here).
Hope that helps!
The Mono version available in the Ubuntu 12.04 repositories is very old. Try with a newer Mono (e.g. the one in Ubuntu 14.04) and see if that works.

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.

My Application not allow Interop.CDO to download a file

My Application does not allow Interop.CDO to download a file from FTP server, what can I need to do to resolve this issue?
Error message :
Could not load file or assembly
'Interop.CDO, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null'
or one of its dependencies. Была
сделана попытка загрузить программу,
имеющую неверный формат.
Here's the English equivalent of the error:
An attempt was made to load a program with an incorrect format.
Can you check it's not a 32/64 bit issue? The underlying COM CDO dll is probably only supporting 32-bit processes. Your program maybe compiled as "x64" or as "Any CPU", but running on a 64-bit Windows.

Categories

Resources