如果你对编程和开发AutoCAD.net 插件还是新手,那么AutoCAD开发者中心最近发布的“My First AutoCAD Plug-in”系列课程绝对值得一看。这个课程面向编程零基础但想对AutoCAD进行扩展的童鞋们。你可以使用免费的Visual Studio Express版本来开发。 AutoCAD开发者中心还提供了The AutoCAD 2010-2012 .NET Wizards项目向导,帮助你来快速的创建一个AutoCAD.net插件,并且这个向导还能帮你做好在Visual Studio Express版本中启动AutoCAD进行调试的相关设置,而这在Visual Studio Express的界面中的没有的。
如果你使用VB.net Express 2010 并利用The AutoCAD 2010-2012 .NET Wizards创建了一个AutoCAD.net 插件,按F5启动调试时,在”即时”窗口中可能会发现很多错误。这些错误并不影响你程序的运行,但你往往需要等待好长时间才能开发调试工作。
相关的错误信息类似:
'----Immediate Window--------------------------------------
System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='<null>' BindingExpression:Path=AutomationName; DataItem='ToolBarCustomizeButton' (HashCode=44123454); target element is 'ToolBarToggleButton' (Name='mCustomizeButton'); target property is 'Name' (type 'String')
System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='<null>' BindingExpression:Path=AutomationName; DataItem='ToolBarCustomizeButton' (HashCode=44123454); target element is 'ToolBarToggleButton' (Name='mCustomizeButton'); target property is 'Name' (type 'String')
System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='<null>' BindingExpression:Path=AutomationName; DataItem='ToolBarCustomizeButton' (HashCode=44123454); target element is 'RibbonItemControl' (Name=''); target property is 'Name' (type 'String')
System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='<null>' BindingExpression:Path=AutomationName; DataItem='InfoCenterTextBox' (HashCode=52380055); target element is 'RibbonItemControl' (Name=''); target property is 'Name' (type 'String')
System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='<null>' BindingExpression:Path=AutomationName; DataItem='InfoCenterTextBox' (HashCode=52380055); target element is 'Button' (Name='PART_AcceptButton'); target property is 'Name' (type 'String')
System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='<null>' BindingExpression:Path=AutomationName; DataItem='WebServicesLoginButton' (HashCode=720995); target element is 'LoginButtonRibbonItemControl' (Name='mContainer'); target property is 'Name' (type 'String')
System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='<null>' BindingExpression:Path=AutomationName; DataItem='RibbonToggleButton' (HashCode=43678569); target element is 'RibbonItemControl' (Name=''); target property is 'Name' (type 'String')
System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='<null>' BindingExpression:Path=AutomationName; DataItem='WebServicesLoginButton' (HashCode=720995); target element is 'WebservicesLoginButtonControl' (Name='mDropDownButton'); target property is 'Name' (type 'String')
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='Autodesk.Private.Windows.ToolBars.ToolBarControl', AncestorLevel='1''. BindingExpression:Path=IsVisible; DataItem=null; target element is 'ImageControl' (Name='mImage'); target property is 'NoTarget' (type 'Object')
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='Autodesk.Private.Windows.ToolBars.ToolBarControl', AncestorLevel='1''. BindingExpression:Path=IsVisible; DataItem=null; target element is 'ImageControl' (Name='mImage'); target property is 'NoTarget' (type 'Object')
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='Autodesk.Private.Windows.ToolBars.ToolBarControl', AncestorLevel='1''. BindingExpression:Path=IsVisible; DataItem=null; target element is 'ImageControl' (Name='mImage'); target property is 'NoTarget' (type 'Object')
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='Autodesk.Private.Windows.ToolBars.ToolBarControl', AncestorLevel='1''. BindingExpression:Path=IsVisible; DataItem=null; target element is 'ImageControl' (Name='mImage'); target property is 'NoTarget' (type 'Object')
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='Autodesk.Private.Windows.ToolBars.ToolBarControl', AncestorLevel='1''.
解决的办法就是添加下面的 <system.diagnostics>节到 Acad.exe.Config中,这个文件可以在你的AutoCAD安装目录中找到:
<system.diagnostics> <sources> <source name="System.Windows.Data" switchName="SourceSwitch"> <listeners> <remove name="Default" /> </listeners> </source> </sources> </system.diagnostics>
添加完成后,类似下面的样子(这里我使用的是Civil 3D):
<configuration> <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0"/> </startup> <!--All assemblies in AutoCAD are fully trusted
so there's no point generating publisher evidence--> <runtime> <generatePublisherEvidence enabled="false"/> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <probing privatePath="bin\FDO;bin;Plugins\Workflow\Activities"/> </assemblyBinding> </runtime> <system.diagnostics> <sources> <source name="System.Windows.Data" switchName="SourceSwitch"> <listeners> <remove name="Default" /> </listeners> </source> </sources> </system.diagnostics> </configuration>
希望对你有帮助。