Use Bouncy Castle library with .NET Compact Framework

試著忘記壹切 提交于 2019-12-07 11:30:26

问题


I’m trying to use Bouncy Castle v1.7 on a Windows Mobile 6.5 device.

I’m trying to execute the following code:

ISigner signer = SignerUtilities.GetSigner("SHA256withRSA");

Using the Bouncy Castle binaries

On the Windows Mobile device, the code results in the following exception being thrown:

"The version of the assembly System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=B77A5C561934E089 cannot be loaded by this version of the Microsoft .NET Compact Framework."

On a classic desktop application (using the whole .NET framework), this code runs without problem.

So I’m guessing there is an incompatibility between Bouncy Castle and the Compact Framework. However the Bouncy Castle C# index page says “Source now builds on .NET Compact Framework 1.0” for version 1.2

Compiling Bouncy Castle from source-code

I've also tried to compile Bouncy Castle from its source-code.
I've compile it using Visual Studio 2008 (had to convert the project and remove classes linked to the IDEA encryption algorithm that were referenced but missing) with the following compilation symbols: NET_1_1;NETCF_2_0

When I reference the DLL resulting from the compilation and run the code mentioned above (on a Device) I get the following exception:

"Method not found: GetSigner Org.BouncyCastle.Security.SignerUtilities."

This seems really strange since I get IntelliSense in Visual Studio while coding.

Can someone tell me how to get Bouncy Castle running on Compact Framework 3.5 ?

Thanks a lot,
Christophe


回答1:


I created the required files and put the SLN/CSPROJ files up on my blog. I created a very simple test app that successfully created an ISigner implementation instance. This was my consumer code:

class Program
{
    static void Main(string[] args)
    {
        ISigner signer = SignerUtilities.GetSigner("SHA256withRSA"); 
    }
}


来源:https://stackoverflow.com/questions/6859886/use-bouncy-castle-library-with-net-compact-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!