我在从MS Visual Studio 2010运行应用程序时遇到问题。实际上这是一个很长的故事,我之前遇到过不同的相关问题。但该项目至少工作了半年没有变化。现在我想再次运行它,但没有效果。起初这里有一些关于相关问题的链接似乎是相同的(但看起来不一样 - 只是相关的):
File (or assembly) can't be found after changing project's .NET target-framework from 4.0 to 3.5
Downgrade an application from .net 4.0 to 3.5
Issues with RESX files on VS2010 targeting 3.5 framework
我的项目有TargetFramework = 2.0,它包含很少的resx资源文件,其中包含应用程序的图像和图标。我曾经遇到资源文件编译问题,但修复了它们,就像上面链接中的帖子一样。所有工作都很好,直到昨天(我没有长时间打开那个项目,所以不能说环境究竟发生了什么变化)。
现在问题本身:项目构建成功,但是当运行应用程序时,我在表单设计器代码'resources中获得了FileNotFoundException。 GetObject (“myImageName” )':
Could not load file or assembly 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.
at System.RuntimeTypeHandle._GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, Boolean loadTypeFromPartialName)
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
at System.RuntimeType.PrivateGetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
at System.Type.GetType(String typeName, Boolean throwOnError)
at System.Resources.ResourceReader.FindType(Int32 typeIndex)
at System.Resources.ResourceReader.DeserializeObject(Int32 typeIndex)
at System.Resources.ResourceReader.LoadObjectV2(Int32 pos, ResourceTypeCode& typeCode)
at System.Resources.ResourceReader.LoadObject(Int32 pos, ResourceTypeCode& typeCode)
at System.Resources.RuntimeResourceSet.GetObject(String key, Boolean ignoreCase, Boolean isString)
at System.Resources.RuntimeResourceSet.GetObject(String key, Boolean ignoreCase)
at System.Resources.ResourceManager.GetObject(String name, CultureInfo culture, Boolean wrapUnmanagedMemStream)
at System.Resources.ResourceManager.GetObject(String name)
[MYAPP stack trace part. Hope you don't need it]
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
我问了关于this problem on Microsoft site的问题,并找到了另外一个有完全相同问题的人。但他的问题被忽略了,我也没有回答。
环境: Windows 7 x64,.NET 4.0 SP1,VS 2010 Ultimate SP1。项目构建配置:Debug / AnyCPU(我试过AnyCPU / x86的Debug / Release - 完全相同.x64和IA64 - 这个项目是不可能的)
调查详情: