Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
480 views
in Technique[技术] by (71.8m points)

.net 4.0 - Unable to resolve assemblies that use Portable Class Libraries

I'm having a problem with assembly resolution on an end-user machine and I believe it's related to using Portable Class Libraries....

I have a .NET 4.0 application that was originally written in Visual Studio 2010. Recently we upgraded to Visual Studio 2012 and we've created a few projects that are Portable Class Libraries. I don't believe we need these features now, but we're also building a Windows 8 Store application that might benefit from these libraries.

When I compile my project, what exactly does the portable library feature do? I expect that it allows me to run it on different frameworks without modification or recompiling.

When I look at the library in reflector dotPeek it shows the Platform attribute as:

.NETPortable,Version=v4.0,Profile=Profile5

And the references seem 2.0-ish:

mscorlib, Version=2.0.5.0

System, Version=2.0.5.0

System.Runtime.Serialization, Version=2.0.5.0

When I run the application on this end-user's machine, I see an error in the log file:

Could not load file or assembly, 'System.Core, Version=2.0.5.0...'

Googling System.Core 2.0.5.0 seems to refer to SilverLight -- which appears to be one of the targeted frameworks.

This machine does not have Visual Studio installed, but has .NET 4.0 (4.0.3 update)

Is there something I should be doing differently to compile, something I should investigate in my dependencies or something I should be looking to install on the end-user machine? What does the 2.0.5.0 refer to?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

For .NET 4, you need an update (KB2468871) for Portable Class Libraries to work. From the KB Article:

Feature 5

Changes to the support portable libraries. These changes include API updates and binder modifications. This update enables the CLR to bind successfully to portable libraries so that a single DLL can run on the .NET Framework 4, on Silverlight, on Xbox, or on the Windows Phone. This update adds public Silverlight APIs to the .NET Framework 4 in the same location. The API signatures will remain consistent across the platform. All modifications are 100 percent compatible and will not break any existing code.

Also see the "Deploying A .NET Framework App" section of the MSDN Portable Class Library Documentation.

EDIT: Actually, if the machine has .NET 4.0.3 installed as you mention, that should be sufficient. Can you double-check to make sure that it is actually installed?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...