Missing "ADODB" assembly with Mono? - c#

I'm trying to port some ASP.Net code to mono. I am testing it using xsp2. I compile it with Visual Studio also before running it with xsp2.
Whenever I go to a practically blank page in my application I get
Parser Error Message: Assembly ADODB, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A not found
I have searched and not found any info anywhere about this. I know the web application makes use of Webparts and the SqlPersonalization thing which is not supported in Mono, but I'm going to basically a blank page with a master page and getting this strange error.
And I have ran Moma and it only complained about web parts and SqlPersonalization, neither of which are on the page I'm trying to view(or referenced in any way).
What could be the problem here? Has someone hit a problem like this before? Also I'm using the latest version of Mono on Windows

ADODB is the primary interop assembly for the old Microsoft ActiveX Data Objects (ADO, aka MDAC) COM-based database access layer. Looks like the ASP.NET code you're trying to port uses an older, non-.NET data access library for some reason. I suspect that library doesn't, and never will, exist on Mono.
One solution would be to port the code that uses ADO to ADO.NET, if that's possible.

Related

Type name "OleDbDataAdapter" could not be found in the namespace "System.Data.OleDb"

When making a project in WPF C# (.NET 5.0), I wanted to use data from my database. I have a Microsoft Access file (2000-2003 compatible version, *.mdb), which I needed to use for my project.
After I added new source
Add > new Item... > Data > DataSet and specified properly the database (the connection was tested successful), file DataSetProj.xsd has been created.
However, when I tried running the code, the following error occurred:
Error CS1069: The type name 'OleDbDataAdapter' could not be found in the namespace 'System.Data.OleDb'. This type has been forwarded to assembly 'System.Data.OleDb, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' Consider adding a reference to that assembly.
When clicking the CS1069 hyperlink, this site opened (unfortunately, no specifics on the error were provided).
Trying to fix the error myself, I found System.Data.OleDb namespace documentation. Here's my interesting observation: The code automatically generated by DataSetProj.Designer.cs file had classes (supposedly defined in the namespace), like OleDbConnection, or OleDbDataAdapter. Funnily enough, this namespace mentions these classes, but it appears they are not part of the namespace (although this is official MS documentation). When I enter documentation of either of the classes, they are included in the System.Data.Ole.Db namespace. This is weird and super unclear (at least for me, junior dev) documentation.
I tried switching to .NET 4.8 Framework, use EF Core Power Tools by ErikEJ (unfortunately it doesn't work with Access *.mdb file). I could not find the answer to this problem anywhere, although it seems like many people would have such an issue.
How do I make it work?
I noticed that the namespace System.Data.OleDb referenced in OleDbDataAdapter class is located in System.Data.OleDb.dll Assembly. When googled the name of the assembly, I found this link. After downloading and installing the assembly (using NuGet Package Manager), the error was resolved.
I hope that other people having the same issue will have it fixed upon visiting this post.
System.Data.OleDb is not part of .Net 5 but is available as part of the .Net Platform Extensions. See below link for more details on .Net Platform Extensions:
What are .NET Platform Extensions on learn.microsoft.com?
If ok with exclusively targeting Microsoft Windows Platform, you can consider installing the windows compatibility pack which includes the OleDb dll as well (below link) or consider rewriting your code to avoid OleDb (ODCB or ADO maybe?):
https://www.nuget.org/packages/Microsoft.Windows.Compatibility

Unable to load file or assembly mongocrypt

System.BadImageFormatException: 'Could not load file or assembly 'mongocrypt' or one of its dependencies. The module was expected to contain an assembly manifest.'
I have a project that runs Hangfire 1.7.5 with MongoDB 2.9.1.0. This project is used as a backend engine to perform various types of work.
In order to create endpoints for outside systems to call this engine, we have another project that uses the same versions of Hangfire and MongoDB to connect and pass in the jobs for processing.
I upgraded Hangfire and Mongo to the latest versions, 1.7.9 and 2.10.1.0 respectively in all the projects that were using these dlls. Using Visual Studio, when I run the web projects, I keep getting the above mentioned error. I get these like 4 to 5 times before the ASP.Net site loads up and allows me to access anything I need, including the data that is accessed via MongoDB. Just an inconvenience but still an exception when loading project.
I know that architecture of the CPUs might cause the System.BadImageFormatException but nothing in that sense has been changed. I am running everything on .net 4.6.1 and everything continues to run on AnyCPU configuration. If I change all these projects to x64 or x86, one or the other thing stops working. mongocrypt error continues to occur regardless of the CPU architecture.
I cant find anything on google or SO regarding mongocrypt. Any ideas?
Same thing happened to us.
It appears that in v2.10.0 a new dependency library was introduced libmongocrypt
that causes this error.
Try to go back to v2.9.3 to workaround this issue until it is fixed by mongodb programmers.
mongodblibmongocryptc#

Could not load an assembly despite it being referenced

I'm looking at incorporating the new Google Apps Script Execution API into an existing C# plugin i have already working. I am following the .NET quickstart guide provided as a console application (which i have gotten working without problem).
When porting the code from that into my plugin it will also fail at runtime at the first instance of:
UserCredential credential;
which I slimmed down the code so far to just that line which fails giving:
"Could not load file or assembly 'Google.Apis.Auth, Version=1.9.2.27817, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab' or one of its dependencies. The system cannot find the file specified."
The file is properly referenced (having installed via nuget).
C# is not my normal field and perhaps i'm missing something in the subtlety of it working in a Console App.
What gives?
There was a time when console apps defaulted to using the client profile rather than the full .Net framework. Check the properties of the project on the Application tab and make sure the target framework doesn't end with Client profile. If that doesn't work try using the fusion log viewer, which you'll find conviently located at C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin, or any number of other places. Run it as an admin and it'll tell you what it can't load (which may or may not be Google.Apis.Auth) and where it looked for the file at.
This has been a little bit of a red herring. Not very well documented is the fact for the app i am building against, Autodesk Navisworks,
plugin dependency libraries have to be duplicated in a separate directory altogether from the plugins directory.
Easily fixed for the build environment, but will need a little more thought for when creating a distributable.

Errors trying to load an assembly in C#

Ok this question is more about understanding what the issues are as I dont think anyone will be able to tell me how to fix the problem.
I am writing a .net 4 application and I have a 3rd party dll ( hasp dongle protection ) that I want to reference.
Visual studio allows me to create the reference fine and use classes contained within the dll within my code.
The first issue occurs when the program is run and the dll is actually loaded. I then get the following error.
System.BadImageFormatException: Could not load file or assembly
'hasp_net_windows.dll' or one of its dependencies. is not a valid
Win32 application
This weblink states how to fix this error. Coud someone expalain what the issue is and why im getting it.
After following this advice I then set the main project build to x86 and I then get another error replacing the other. The new error is:
System.IO.FileLoadException: Mixed mode assembly is built against
version 'v1.1.4322' of the runtime and cannot be loaded in the 4.0
runtime without additional configuration information
This weblink states how to fix the error, but I dont have an app.config in my project and want to avoid having one if at all possible. If someone could explain what the issue is again that would be helpful?
Please let me know if you require anymore information.
The issue is the "bitness" of your application. Once chosen (32 bit or 64 bit) all DLLs within that process need to be the same. This exception tells me that one of your DLLs is the wrong "bitness".
You simply cannot have DLLs with different compilation targets within a given process, a process has "bitness" affinity.
If this is a third party unmanaged DLL then it is very likely 32-bit compiled.
Setting the build output as x86 for the root project (the one that creates the exe) should suffice as this will dictate the process that is created. Any other .NET projects can then simply be Any CPU and will fit in either the 32 or 64 bit runtimes.
Unfortunately for your second issue, the provided link is the way to solve it. There is nothing wrong with having an app.config in a project and you haven't stated why you don't want one.
The answer by Adam Houldsworth notwithstanding, I'd like to add that it is possible to do it without an app.config. However, this requires a tiny bit more work and potentially a proper understanding of COM interop. Whether it's worth the trouble is up to you of course ;).
You can set useLegacyV2RuntimeActivationPolicy programmatically by using the ICLRRuntimeInfo::BindAsLegacyV2Runtime method.
A quick rundown on how to do this is posted in this blogpost. Take note of his warning though, which might make you think twice in using this approach:
This approach works, but I would be very hesitant to use it in public
facing production code, especially for anything other than
initializing your own application. While this should work in a
library, using it has a very nasty side effect: you change the runtime
policy of the executing application in a way that is very hidden and
non-obvious.
I cannot use an app.config file because the assembly is loaded via COM from a native program.
I found the library that supports .net framework 4.0. here. In this scenario, no other solutions had worked for me.

Windows Forms app, exception on start-up: Could not load System.Xml

Update: I have tried using fuslogvw.exe to get logs. But what exactly am I looking for? Sadly, the logs are in Danish which is extremely annoying (Apparently someone thought that translating everything literaly into Danish inside error log-messages would be a good idea, but it basically renders Google useless: I have to guess at the original english text to get good hits, grrrr). I Think the translation should go something like:
"LOG: Start bind of original image System.Windows.Forms.resources, Version=2.0.0.0, Culture=da-DK, PublicKeyToken=b77a5c561934e089.
WRN: No matching original image was found".
I'm quite new to these logs, so suggestions are still velcome.
I have a Windows Forms application, which stores settings using Properties.Settings...
I recently downloaded and installed another .Net application. Now all of a sudden my own Windows Forms application throws an exception immediately when starting (where I try to load the settings). The error says something like "file or assembly System.Xml, Version=2.0.0.0, PublicKeyToken= b77a5c561934e089 or one of its dependencies could not be loaded. The module was expected to contain an assemblymanifest".
I have no clue as to where to look for the cause of this error, since the Windows\assembly folder contains System.Xml with correct version and public, key.
Suggestions are most welcome, especially with reference to .Net documentation I should read up on, since I feel this is a big gap in my .Net knowledge.
Thank you!
This is partly a guess, but it's worth a try.
Take a look in your app.config file. Look for any configuration that references System.XML. If you find any, try removing the version number from the binding. I had a similar kind of issue with multiple versions of the enterprise library.
If that doesn't help you can use the assembly binding log viewer (fuslogvw.exe) to get more information on the binding failure. You have to start it up and enable logging of all bindings (or just failures if you prefer), then make sure your logs are cleared, run your app, hit refresh and look through the binding logs for the System.XML failure. This will provide you with information on where the runtime is looking for the assembly, and why the bind failed.
Make sure .NET 2.0 is installed on your machine (if only .NET 3.0 is installed it's not enough). Could you please provide more information regarding what framework version your original application is compiled against? Let me know if it helped

Categories