.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

My first .NET code with lots of errors, please need help.

22 REPLIES 22
Reply
Message 1 of 23
junoj
1635 Views, 22 Replies

My first .NET code with lots of errors, please need help.

Hi everyone,
I am having a difficult time understanding the errors that the .NET API is giving me. When I run my first code:

'---code--------------------------------------
Imports Autodesk.AutoCAD.Runtime

Public Class vbstudentClass

' Define command 'NewCmd1'
_
Public Sub NewCmd1()
MsgBox("NewCmd1")
' Type your code here

End Sub

End Class
'----Immediate Window--------------------------------------

System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='NaN' BindingExpression:Path=Source.MinimumWidth; DataItem='ToolBarControl' (Name=''); target element is 'ToolBarControl' (Name=''); target property is 'MinWidth' (type 'Double')
System.Windows.Data Error: 39 : BindingExpression path error: 'BackgroundOpacity' property not found on 'object' ''ContentPresenter' (Name='PART_CustomizeButtonInMainPanel')'. BindingExpression:Path=BackgroundOpacity; DataItem='ContentPresenter' (Name='PART_CustomizeButtonInMainPanel'); target element is 'SystemDropShadowChrome' (Name='Shdw'); target property is 'Opacity' (type 'Double')
System.Windows.Data Error: 39 : BindingExpression path error: 'Current' property not found on 'object' ''QuickAccessUndoControl' (HashCode=32115247)'. BindingExpression:Path=Current; DataItem='QuickAccessUndoControl' (HashCode=32115247); target element is 'ContentPresenter' (Name=''); target property is 'NoTarget' (type 'Object')
System.Windows.Data Error: 39 : BindingExpression path error: 'Current' property not found on 'object' ''QuickAccessRedoControl' (HashCode=6503226)'. BindingExpression:Path=Current; DataItem='QuickAccessRedoControl' (HashCode=6503226); target element is 'ContentPresenter' (Name=''); target property is 'NoTarget' (type 'Object')
System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='NaN' BindingExpression:Path=Source.MinimumWidth; DataItem='InfoToolbar' (Name='InfoCenter'); target element is 'InfoToolbar' (Name='InfoCenter'); target property is 'MinWidth' (type 'Double')
System.Windows.Data Error: 39 : BindingExpression path error: 'BackgroundOpacity' property not found on 'object' ''ContentPresenter' (Name='PART_CustomizeButtonInMainPanel')'. BindingExpression:Path=BackgroundOpacity; DataItem='ContentPresenter' (Name='PART_CustomizeButtonInMainPanel'); target element is 'SystemDropShadowChrome' (Name='Shdw'); target property is 'Opacity' (type 'Double')
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'ElementName=mToggleButton'. BindingExpression:(no path); DataItem=null; target element is 'RibbonItemControl' (Name=''); target property is 'KeyTipPlacementTarget' (type 'UIElement')
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'ElementName=mToggleButton'. BindingExpression:(no path); DataItem=null; target element is 'RibbonItemControl' (Name=''); target property is 'KeyTipActivationTarget' (type 'UIElement')
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'ElementName=mText'. BindingExpression:(no path); DataItem=null; target element is 'RibbonItemControl' (Name=''); target property is 'KeyTipPlacementTarget' (type 'UIElement')
System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=BackgroundBorderColor; DataItem=null; target element is 'SolidColorBrush' (HashCode=5425146); target property is 'Color' (type 'Color')


Thank you,

-Jay
22 REPLIES 22
Message 2 of 23
Anonymous
in reply to: junoj

In Visual Studio, choose Tools->Options, and in the left
pane of the dialog, select the "Debugging" item.

On the right side, check "Enable Just My Code".


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2011

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6393678@discussion.autodesk.com...
Hi everyone,
I am having a difficult time understanding the errors that the .NET API is
giving me. When I run my first code:

'---code--------------------------------------
Imports Autodesk.AutoCAD.Runtime

Public Class vbstudentClass

' Define command 'NewCmd1'
_
Public Sub NewCmd1()
MsgBox("NewCmd1")
' Type your code here

End Sub

End Class
'----Immediate Window--------------------------------------

System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid
for target property.; Value='NaN' BindingExpression:Path=Source.MinimumWidth;
DataItem='ToolBarControl' (Name=''); target element is 'ToolBarControl'
(Name=''); target property is 'MinWidth' (type 'Double')
System.Windows.Data Error: 39 : BindingExpression path error:
'BackgroundOpacity' property not found on 'object' ''ContentPresenter'
(Name='PART_CustomizeButtonInMainPanel')'.
BindingExpression:Path=BackgroundOpacity; DataItem='ContentPresenter'
(Name='PART_CustomizeButtonInMainPanel'); target element is
'SystemDropShadowChrome' (Name='Shdw'); target property is 'Opacity' (type
'Double')
System.Windows.Data Error: 39 : BindingExpression path error: 'Current' property
not found on 'object' ''QuickAccessUndoControl' (HashCode=32115247)'.
BindingExpression:Path=Current; DataItem='QuickAccessUndoControl'
(HashCode=32115247); target element is 'ContentPresenter' (Name=''); target
property is 'NoTarget' (type 'Object')
System.Windows.Data Error: 39 : BindingExpression path error: 'Current' property
not found on 'object' ''QuickAccessRedoControl' (HashCode=6503226)'.
BindingExpression:Path=Current; DataItem='QuickAccessRedoControl'
(HashCode=6503226); target element is 'ContentPresenter' (Name=''); target
property is 'NoTarget' (type 'Object')
System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid
for target property.; Value='NaN' BindingExpression:Path=Source.MinimumWidth;
DataItem='InfoToolbar' (Name='InfoCenter'); target element is 'InfoToolbar'
(Name='InfoCenter'); target property is 'MinWidth' (type 'Double')
System.Windows.Data Error: 39 : BindingExpression path error:
'BackgroundOpacity' property not found on 'object' ''ContentPresenter'
(Name='PART_CustomizeButtonInMainPanel')'.
BindingExpression:Path=BackgroundOpacity; DataItem='ContentPresenter'
(Name='PART_CustomizeButtonInMainPanel'); target element is
'SystemDropShadowChrome' (Name='Shdw'); target property is 'Opacity' (type
'Double')
System.Windows.Data Error: 4 : Cannot find source for binding with reference
'ElementName=mToggleButton'. BindingExpression:(no path); DataItem=null; target
element is 'RibbonItemControl' (Name=''); target property is
'KeyTipPlacementTarget' (type 'UIElement')
System.Windows.Data Error: 4 : Cannot find source for binding with reference
'ElementName=mToggleButton'. BindingExpression:(no path); DataItem=null; target
element is 'RibbonItemControl' (Name=''); target property is
'KeyTipActivationTarget' (type 'UIElement')
System.Windows.Data Error: 4 : Cannot find source for binding with reference
'ElementName=mText'. BindingExpression:(no path); DataItem=null; target element
is 'RibbonItemControl' (Name=''); target property is 'KeyTipPlacementTarget'
(type 'UIElement')
System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or
FrameworkContentElement for target element.
BindingExpression:Path=BackgroundBorderColor; DataItem=null; target element is
'SolidColorBrush' (HashCode=5425146); target property is 'Color' (type 'Color')


Thank you,

-Jay
Message 3 of 23
junoj
in reply to: junoj

Hi Tony. Thank you for helping me out again.

I am using the 2008 Express Edition, I can't find the option under the Express Edition. Do you happen to know if I can do the same under the Express Edition.

Thank you,

-Jay
Message 4 of 23
Anonymous
in reply to: junoj

Sorry, I'm not too familar with the Express edition,
but on reflection, this may not be the problem.

In your project properties, select both the acmdg.dll
and acdbmdg.dll references, and set their 'CopyLocal'
property to false.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2011

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6394130@discussion.autodesk.com...
Hi Tony. Thank you for helping me out again.

I am using the 2008 Express Edition, I can't find the option under the Express
Edition. Do you happen to know if I can do the same under the Express Edition.

Thank you,

-Jay
Message 5 of 23
ViktorCAD
in reply to: junoj

You having a hard time building your application? or are you getting an error when running the application?

you should be able to see the errors dialog box if you hit CNTRL + E.
Message 6 of 23
junoj
in reply to: junoj

Hi Viktor,

I tried the CNTRL + E, but nothing really happen.

When I run the code, the code opens AutoCAD but i do not get any messages. I get a list of errors, i listed the errors above.

Please help,

Thank you,

-Jay
Message 7 of 23
junoj
in reply to: junoj

Hi Viktor, I got it now. . . . .

I was thinking VBA. I did not realize that I had to load the dll files independently.

Thank you,

-Jay
Message 8 of 23
Mikko
in reply to: junoj

This may or may not apply to you but I thought just in case you never heard of this program, that I'd supply a link to Dreamspark, https://www.dreamspark.com/default.aspx which has all the Microsoft tools you'll need {color:#0000ff}FREE{color}. All you need be is in High School or College and have a school supplied email address with the extension .edu. If your school is not on the list there is information as to how to get the software on the site. Nothing wrong with the express versions, but here is a chance to get even more if your eligible.

Message 9 of 23
junoj
in reply to: junoj

That is grate Mikko. I will defiantly give it a try. I am not sure how much I will gain from upgrading to Pro vs. Express. Perhaps someone can give us some inside on which VB.net API is the best for AutoCAD programming, and why.

Thank you,

-Jay
Message 10 of 23
mfernandes
in reply to: junoj

 any solution to this issue yet!!!

 

I am using VS Express 2010, Win 7-32, and Map3D 2012 and getting the same errors.

Cannot ignore the errors as it takes considerable amount of time for all the errors before I can actually start working.

 

Message 11 of 23
AubelecBE
in reply to: mfernandes

hi i am new to but with VS2010 express and autocad v2010 but now i know..

So check  :

 

VS2010 :

menu project --> ProjetName propertie

Go to tab "compile"

click on button bottom of this windows "Advanced Compile Options..."

--> Target Framework :

here you have to check the framework version example :

for Autocad 2010 --> v3.5

for autocad 2012 --> v4.

 

Now go to tab "References"

you need have acdbmgd and acmgd      the 2 DLL you found it in the path of autocad. c:\program files\autocad2010\....  for me.

For add this click on button "Add.."

 

save your project, buid. and try..

 

For me in v2010 autocad i have to modify a file in the path of autocad but you in v2012 on autocad map i dont know.

 

 

example  for a single prog :

Imports Autodesk.AutoCAD.Runtime
Public Class Start
    <CommandMethod("ProgAR", CommandFlags.Session)> _
    Public Sub ProgAR()

               MsgBox("Txt !", vbOKOnly ,"Erreur PROG")
    End Sub 'End Command



End Class


 

Message 12 of 23
mfernandes
in reply to: AubelecBE

 

Thanks AubelecBESmiley HappyI already have it set to compile for Framework 4 and all AutoCAD references are set to false copy local.

 

I pinged AutoDesk for help and the message was that the errors are information only and do not create a problem so I should ignore them. The code will compile and run.

 

Their options were to switch to C# or update to VS pro where these error do not occur........ so pretty much, I was 

politely told to, suck it up princess, deal will the list of error messages or buy VS pro.

 

Hope someone can shed some light on these errors, it is a pain having to wait for the errors to finish listing before I can start debugging.

 

Message 13 of 23
Daniel.Du
in reply to: mfernandes

try this workaround:

 

Add the following to the acad.exe.config file.

 

  <system.diagnostics>

    <sources>

      <source name="System.Windows.Data" switchName="SourceSwitch">

        <listeners>

          <remove name="Default" />

        </listeners>

      </source>

    </sources>

  </system.diagnostics>



Daniel Du
Developer Technical Services
Autodesk Developer Network

Message 14 of 23
mfernandes
in reply to: AubelecBE

Thanks, Daniel.... that seemed to work. Smiley Happy

cheers

 

Message 15 of 23

I have the same problem, but that solution (adding to the config file) simply crashes autocad on startup.

 

The program that I'm writing (literally, the hello world provided in one of the help videos) has a bunch of errors in the loading phase, the helloworld command doesn't work when it is complete.

 

Anyone got any other ideas?

Message 16 of 23

Hi,

 

>> I have the same problem

Just to make sure as this thread is quite long and there are different issues listed: what is "the same problem"? Same to what?

 

>> has a bunch of errors in the loading phase

What AutoCAD release and what Visual-Studio are you working with and what errors are these (copy them to a TXT-file and attache this here)?

 

>> the helloworld command doesn't work

So you get a "unknown command" message after NETLOADing it? Or what else happens?

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 17 of 23

> "the same problem"? Same to what?

 

The same as the OP.  first message in the thread.

 

>  What AutoCAD release and what Visual-Studio are you working with and what errors are these (copy them to a TXT-file and attache this here)?

 

I have both AutoCAD Map 2012 and AutoCAD Plant3D 2012.  I also have Visual Studio 2010 on a Windows 7 64-bit system.

 

>  So you get a "unknown command" message after NETLOADing it? Or what else happens?

 

That's it.  AutoCAD starts, lots of errors in the debug window back in VS2010, and the command is not loaded. ("helloworld").  I can continue using autocad if I want to... until i hit the stop button in the VS2010 debug area of course.

 

Netload?  That shouldn't be necessary at this point... The code that I'm running is...

 

 

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.ApplicationServices;

namespace Sandbox
{
    public class Sandbox1
    {
        [Autodesk.AutoCAD.Runtime.CommandMethod("helloworld")]
        public void MyHelloWorld()
        {
            //  get the editor object
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;

            //  write to the command line
            ed.WriteMessage("\nHello World!");

        }
    }
}

 

I should be able to just type 'helloworld' and for it to be demand loaded.

 

Doesn't get any less complex than that. 

 

 

I get about a hundred errors, but this is the first one...

 

System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='<null>' BindingExpression:Path=AutomationName; DataItem='ToolBarCustomizeButton' (HashCode=45895697); target element is 'ToolBarToggleButton' (Name='mCustomizeButton'); target property is 'Name' (type 'String')

Message 18 of 23

Hi,

 

do you have this code as a small solution or is the command "helloworld" built into an application with a lot of code?

If first (just this small sample-app) then ZIP the complete solution and upload it.

 

BTW: when I start AutoCAD in debug-mode I also get a lot of messages, most having the source in the ribbons, but as long as the compiler does not give you an error in your code, these messages did never influence my debugging (well I'm always afraid about the guys who developed this ribbon-interface, either at Autodesk nor at Microsoft, because that mass of warnings look like "not finished yet").

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 19 of 23

> do you have this code as a small solution or is the command "helloworld" built into an application with a lot of code?

 

No.  It's a stand-alone solution and class.  That text is the entire text of the class.

 

> If first (just this small sample-app) then ZIP the complete solution and upload it.

 

Done.  Attached.

 

> BTW: when I start AutoCAD in debug-mode I also get a lot of messages, most having the source in the ribbons, but as long as the compiler does not give you an error in your code, these messages did never influence my debugging

 

Yes, it wouldn't bother me, but the actual demand loaded command doesn't actually work.  I could deal with error messages if the command actually accomplished its objective.  But when I type the command that should now be demand loaded, it just does this...

 

 

Command: helloworld
Unknown command "HELLOWORLD". Press F1 for help.

 


Message 20 of 23

I've even attached a cut-paste of the VS2010 output window... 

 

 

650K long...

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost