[Map 3D开发实战系列] Map Resource Explorer 之四-- Map3D开发中的WPF
目錄
[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選項卡可以快速的幫我找到最近用過的程序集,還是很方便的。
?
好了,先到這里,現在你可以開始設計你的基于Map 3D應用程序WPF界面了。
?
Cheers,
峻祁連
轉載于:https://www.cnblogs.com/junqilian/archive/2011/02/01/1948618.html
總結
以上是生活随笔為你收集整理的[Map 3D开发实战系列] Map Resource Explorer 之四-- Map3D开发中的WPF的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Javascript权威指南学习笔记一:
- 下一篇: 产品所有者也应该是Scrum教练吗?