JSON .Net Windows Mobile Error when serializing - c#

I am running this bit of code:
string serialized = JsonConvert.SerializeObject(somethingToSend);
And it throws this exception:
MissingMethodException: Could not load type 'System.Runtime.Serialization.StreamingContext' from assembly 'mscorlib, Version=3.5.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC'.
Here is my configuration:
Visual Studio 2008 (with all the latest service packs etc)
Smart Device project targeting Windows Mobile 6 .Net 3.5
Json DotNet version 4.5 Release 7 (referencing the DLL from the WindowsPhone folder in the zip)
The answer to this question "Is there a library to read JSON in C# on Windows Mobile?" implies that it should work.
I am running it in debug with the real device attached (so no emulator) where I have previously installed the CAB file from here without error:
C:\Program Files (x86)\Microsoft.NET\SDK\CompactFramework\v3.5\WindowsCE\NETCFv35.wce.armv4.cab
The application runs fine until I click the button that is running the line above, so does anyone know what I am missing?
This thread "Json.Compact.dll for Windows CE 5.0?" suggests that I would need the Windows SDK installed, which I have. Given it is running on the device itself I guess that is not going to be the fix anyway.
The other suggestion is to build from source but like the author of the question I cannot load the project file into VS 2008 to do that. I could create a new project and include the source files and try to get it to compile but before I do that I thought I would ask here if it is worth it or if there is something else missing from the installation on the device perhaps? Or maybe I should be using an alternate build?

So I needed to RTFM! The readme file says:
Microsoft stopped support for the Compact Framework in Visual Studio 2010.
For a Compact Framework 3.5 build download Json.NET 3.5.
So I grabbed the most recent 3.5 version which is: Json.NET 3.5 Release 8, updated my reference to point to the Newtonsoft.Json.Compact.dll assembly, ran it and it worked fine.

Related

Could not load file System.Drawing.Common but it is not part of my references

Since English is not my native language I'm gonna try to explain myself as clearly as possible.
I have an old project on Visual Basic targeting the .NET Framework version 4.5.2, the project has a reference to System.Drawing dll but no System.Drawing.Common dll reference, when executing the application on my development PC it works fine.
My problem is that when I execute it in a virtual machine that I'm starting to use by requirement of my boss that had no .NET installed, the application cannot found a reference to System.Drawing.Common dll; I already have installed on the virtual machine:
.NET Compact Framework 2.0 (Since my boss told me that it could be some even older dlls)
.NET Compact Framework 3.5 (Since it went with the 2.0 version)
Windows Desktop Runtime 3.0.3 (Cause I found some links that said the dll is part of .NET Core)
Windows Desktop Runtime 3.1.3 (Just in case)
And trying to install any of the .NET 4.x versions tells me that its already installed cause the OS is Windows 10.
Since that seemed not to work I also put a copy of System.Drawing.Common.dll directly in the executable directory and modified the project to load it when the AssemblyResolve event fires. But it still not working, and also I canĀ“t understand why is it requesting that assembly if none of my dlls and exe reference to it.
I'm trying to keep the virtual machine with no developer tools so i'm not sure what else to do. Would be pretty grateful if anyone has some clue of what my problem is. Thank you.
Edit: what makes more noise in my mind is: If System.Drawing.Common is a dll of .NET, shouldn't it be automatically loaded to any .NET application when it is needed? or at least be recovered since I already put the dll in the same folder as the .exe file of my application

Error while using ODAC112040Xcopy_64bit Oracle.DataAccess.dll with Asp.net 4.6 framework

I am using 64bit Oracle.DataAccess.dll (64-bit ODAC 11.2 Release 6 (11.2.0.4.0) Xcopy for Windows x64). Downloaded this package ODAC112040Xcopy_64bit.zip from
http://www.oracle.com/technetwork/database/windows/downloads/index-090165.html.
I want to connect to Oracle 11g Database using the provider dll. I was able to install it successfully. However, when I use the dll in my Asp.net code, I am getting following error.
Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'Oracle.DataAccess, Version=2.112.4.0, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. The system cannot find the file specified.
My system is a Windows 7, 64bit machine. Using Visual Studio 2015. Even before the program execution reaches the function calls of Oracle.DataAccess.dll, I get this error as soon as the page loads.
Have seen many blogs with answers saying, 64-bit dll being used on 32-bit machine or 32-bit enabled IIS Website etc. My requirement is, need only 64bit dll to be executed on 64bit machine.
Please let me know how to fix the issue.
The error message says it is looking for Version=2.112.4.0, which is for .net 2 (and 3). The title of your post mentions .net 4.6, so you should be targeting Version=4.112.4.0 in your visual studio project

.NET 4.0 to 4.5 migration and running on 4.0 machine exception

I have an C# application which is built on Windows Server 2012 with .NET 4.5. Now as part of the other process another machine needs to run this app.
It's probably using Process.Start to execute my .exe file. I can't say 100% because I don't have access to the code. Everything was fine when it was using .NET 4.0 but now when I've migrated to .NET 4.5 it's throwing an exception:
The specified executable is not a valid application for this OS platform
I assumed that the problem is that there is no .NET 4.5 installed on this machine so I've removed this line from the config file to support running on .NET 4.0.
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1"/></startup>
It still haven't helped and the same exception is being thrown.
My application references another libraries which use 4.5.1 framework but it shouldn't matter. I've read somewhere that they are treated as 4.0 application (4.5 features are not used). The build server has also changed from Windows Server 2003 to Windows Server 2012 but it shouldn't matter which OS was used to build, should it? I appreciate for any help.
The specified executable is not a valid application for this OS
platform
Your application should be built using AnyCPU platform. If you try to run an application built with Debug|x64 or Release|x64 on a 32bit OS, the whole executable won't work and you'll get that error.
Update
OP said in some comment:
Issue doesn't seem to be fixed. Does it matter that one of the referenced libraries is forced to use x86 due to C++ references?
Then, you're forced to start the process from a 32bit process.

Referencing assemblies only available on Windows Mobile/CE

I have created a C# project which works as intended when tested on desktop.
However, when I run the executable on a mobile device using .NET CF 3.5 I get the following error: File or assembly name 'System.Windows.Forms, Version=2.0.0.0, etc etc.' or one of its dependencies, was not found.
If I understand correctly, this means that one of the assemblies referenced in the project is "desktop only" and is not present on the mobile device. So how can I get access to the .NET CF 3.5 equivalent and reference it in my project in Visual Studio?
Thanks for any help.
You need to create a "Smart Device Project" to run your application on a Windows CE device. That project type will let you reference CF assemblies only. There are a lot of features that are not supported by the CF version, so your code maybe won't compile.

Error when using Symbol/Motorola Fusion dll - WinCE 6.0

When I run any project from Visual Studio, it works excellent (on Motorola MC 3190 - WinCE 6.0)
However, when I install and run the application on the device, I get this error:
No compatible FusionInterface dll found, Expected version is 4.1.0.1 or higher version having the format 4.x.x.x
What could be the problem?
In my case, deploying Symbol.Fusion.dll and FusionInterface.dll files in the same directory than my executable has resolved this error.
You must install the symbol.all.arm.cab file. If you are using Windows CE then you need the armv4 version. If you are using Windows Mobile, then you need the armv4i version.
Also, make sure there is no local copy of the DLLs in your application's directory; this could be possibly causing a version mismatch.
Adding a reference to Symbol.ResourceCoordination worked for me. Per the CS_FusionSample1 code example included with the Motorola EMDK v2.9, the relevant Symbol references are Symbol, Symbol.Fusion, and Symbol.ResourceCoordination.
Note, I'm building for a Motorola 9190 handheld under Windows CE 6.0.
Fusion Interface DLL Version Compatibility
EMDK for .NET access Fusion Public API via Fusion interface DLL as mentioned in the Overview section. There can be different versions of Fusion Public API and in return many versions of Fusion Interface DLLs.
Version Incompatibility Issue
If this DLL is incompatible with EMDK, an appropriate meaningful error message will be provided in the exception when trying to access Fusion. This occurs when creating Config and WLAN objects.
Possible Messages
Older and incompatible FusionInterface dll 1.0.0.1 found. Expected version is 2.0.0.3 or higher version having the format 2.x.x.x
Newer and incompatible FusionInterface dll 3.1.0.5 found. Expected version is 2.0.0.3 or higher version having the format 2.x.x.x
Solution
The DLL version incompatibility arises because of the two files (Fusion Interface DLL and the Fusion Assembly DLL) taken from different EMDK packages. To fix the issue,
Method 1:
Remove "Symbol Managed Class Libraries" using "Remove Programs" in the control panel of the device.
Check "\Windows" folder of the device for any existence of "FusionInterface.dll" and if so, delete it.
Take the "symbol.all.arm.cab" from EMDK installed location, copy to the device and run installation.
The typical location is the appropriate sub directory (wce400\armv4 or wce500\armv4i) of "\Program Files\Enterprise Mobility Developer Kit for .NET\v2.x\SDK\Smart Devices".
Run the application.
Method2:
Copy the appropriate DLL to the \Windows directory of the device.
Run the application
Note: This DLL is not separately available in the EMDK for .NET package.

Categories

Resources