Portable class library - Reference to type 'MarshalByRefObject' claims it is defined in 'mscorlib', but it could not be found

半世苍凉 提交于 2019-12-08 11:26:26
 using System.Drawing;

That's probably a bit more relevant to what you did to get this error message. You used a sledgehammer to get that using directive recognized. We have to guess at it, but one way you might have done that is with Project > Add Reference > Browse button > pick System.Drawing.dll from the c:\windows\microsoft.net subdirectory. Seems to work just fine.

And presumably you used a similar kind of sledgehammer on mscorlib.dll to get MarshalByRefObject recognized. Although that's much harder to do since the IDE can tell that is not valid, mscorlib.dll is already included in the reference set. Maybe you edited the project file by hand, hard to guess.

Don't use sledgehammers.

A PCL project already has a reference to all of the framework assemblies you can possibly use. They are not listed individually in the References node of your project, they are collapsed in the single ".NET" node.

This isn't done to make your life miserable, it ensures that you cannot accidentally use a class that is not available on one of the targets you selected. Saves you from finding out at the worst possible time, after you've spent weeks writing the code, testing it to perfection on your dev machine and now try to run it on a phone. Kaboom, can't work. Up a creek, no paddle, weeks lost.

System.Drawing is only available on desktop machines. And likewise, MBRO is only available on the full version of the CLR, not the .NETCore version. Can't work, MBRO requires remoting, a feature that was cut from .NETCore to make it "core". You'll have to find another way to accomplish what you want to do. No guidance, the question isn't detailed enough.

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