现在的位置: 首页 > 综合 > 正文

[Map 3D开发实战系列] Map Resource Explorer 之四– Map3D开发中的WPF

2011年08月31日 ⁄ 综合 ⁄ 共 3876字 ⁄ 字号 评论关闭

目录

[Map 3D开发实战系列] Map Resource Explorer 背景介绍--Kick off

[Map 3D开发实战系列] Map Resource Explorer 之二-- 运行和调试

[Map 3D开发实战系列] Map Resource Explorer 之三-- 添加AutoCAD风格的Palette界面

 

如果你已经随着我们前面的文章开始创建基于WPF技术的Map 3D自定义界面的话,你可能会遇到一个比较棘手的问题,就是在Visual Studio 2008中的WPF编辑器中,可视化界面总是显示错误,从而不能想Winform界面设计一样拖控件进去。更麻烦的是两xaml编辑器的智能提示都没有了,这对我这样的WPF菜鸟来说真是要命啊!

 

每次在Visual Studio 2008中打开xaml文件,总是显示下面的错误信息:

An Unhandled Exception has occured.

 

A BadImageFormatException has been thrown while parsing the signature. This is likely due to lack of a generic context. Ensure genericTypeArguments and genericMethodArguments are provided and contain enough context.


   at System.Reflection.Module.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
   at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, Module decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, RuntimeMethodHandle& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
   at System.Reflection.CustomAttribute.GetCustomAttributes(Module decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes)
   at System.Reflection.CustomAttribute.GetCustomAttributes(Assembly assembly, RuntimeType caType)
   at System.Reflection.Assembly.GetCustomAttributes(Type attributeType, Boolean inherit)
   at MS.Internal.Xaml.ReflectionProjectNode.BuildSubsumption()
   at MS.Internal.Xaml.ReflectionProjectNode.SubsumingNamespace(Identifier identifier)
   at MS.Internal.Xaml.XmlElement.BuildScope(PrefixScope parentScope, IParseContext context)
   at MS.Internal.Xaml.XmlElement.FindElementType(PrefixScope parentScope, IParseContext context)
   at MS.Internal.DocumentTrees.Markup.XamlSourceDocument.get_RootType()
   at Microsoft.Windows.Design.Documents.Trees.MarkupDocumentTreeManager.get_RootType()
   at Microsoft.Windows.Design.Documents.MarkupDocumentManager.CalculateLoadErrorState()
   at Microsoft.Windows.Design.Documents.MarkupDocumentManager.get_LoadState()
   at MS.Internal.Host.PersistenceSubsystem.Load()
   at MS.Internal.Host.Designer.Load()
   at MS.Internal.Designer.VSDesigner.Load()
   at MS.Internal.Designer.VSIsolatedDesigner.VSIsolatedView.Load()
   at MS.Internal.Designer.VSIsolatedDesigner.VSIsolatedDesignerFactory.Load(IsolatedView view)
   at MS.Internal.Host.Isolation.IsolatedDesigner.BootstrapProxy.LoadDesigner(IsolatedDesignerFactory factory, IsolatedView view)
   at MS.Internal.Host.Isolation.IsolatedDesigner.BootstrapProxy.LoadDesigner(IsolatedDesignerFactory factory, IsolatedView view)
   at MS.Internal.Host.Isolation.IsolatedDesigner.Load()
   at MS.Internal.Designer.DesignerPane.LoadDesignerView()

Could not load file or assembly 'acmgd, Version=18.1.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.


   at System.ModuleHandle.ResolveType(Int32 typeToken, RuntimeTypeHandle* typeInstArgs, Int32 typeInstCount, RuntimeTypeHandle* methodInstArgs, Int32 methodInstCount)
   at System.ModuleHandle.ResolveTypeHandle(Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
   at System.Reflection.Module.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)

 

这其实是Map 3D 2011的一个bug。前面的文章中介绍了,我们要开发Map 3D 应用程序,需要添加下列的Map 3D相关引用:

Map 3D相关程序集:

Autodesk.Map.Platform.dll

Autodesk.Map.Platform.Core.dll

Autodesk.Map.Platform.Utils.dll;

Autodesk.Gis.Map.Shared.dll;

OSGeo.MapGuide.Foundation.dll

OSGeo.MaoGuide.PlatformBase.dll

 

但引用的上面的Map 3D相关程序集,就会造成Visual Studio 的WPF编辑器工作不正常。当然你可以使用Blend,XamlPad等其他工具来编辑Xaml界面,但对于我们简单的界面设计来说,Blend有点大材小用,而且学习这个软件也得花不少时间。

 

解决的办法就是在设计界面是,暂时把上面的Map 3D相关程序集的引用移除,这样WPF界面编辑器就可以正常工作了。编辑好了界面,需要编译运行时,再重新把这些程序集的引用加进来就行了。Visual Studio引用对话框的Recent选项卡可以快速的帮我找到最近用过的程序集,还是很方便的。

image

 

好了,先到这里,现在你可以开始设计你的基于Map 3D应用程序WPF界面了。

 

Cheers,

峻祁连

抱歉!评论已关闭.