.NET

Reply
Valued Mentor
AubelecBE
Posts: 370
Registered: ‎01-27-2010
Message 11 of 23 (542 Views)

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

02-16-2012 09:55 AM 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


 

Mentor
mfernandes
Posts: 194
Registered: ‎08-21-2007
Message 12 of 23 (514 Views)

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

02-20-2012 09:33 AM in reply to: AubelecBE

 

Thanks AubelecBE:smileyhappy:I 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.

 

Board Manager
Daniel.Du
Posts: 177
Registered: ‎12-23-2008
Message 13 of 23 (474 Views)

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

03-19-2012 07:37 PM 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

Mentor
mfernandes
Posts: 194
Registered: ‎08-21-2007
Message 14 of 23 (434 Views)

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

04-09-2012 10:58 AM in reply to: AubelecBE

Thanks, Daniel.... that seemed to work. :smileyhappy:

cheers

 

Contributor
anthonyperks8274
Posts: 25
Registered: ‎01-30-2011
Message 15 of 23 (409 Views)

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

04-23-2012 10:34 PM in reply to: AubelecBE

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?

*Expert Elite*
Alfred.NESWADBA
Posts: 8,880
Registered: ‎06-29-2007
Message 16 of 23 (406 Views)

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

04-23-2012 10:48 PM in reply to: anthonyperks8274

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
-------------------------------------------------------------------------
Contributor
anthonyperks8274
Posts: 25
Registered: ‎01-30-2011
Message 17 of 23 (402 Views)

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

04-23-2012 10:54 PM in reply to: Alfred.NESWADBA

> "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:smileytongue:ath=AutomationName; DataItem='ToolBarCustomizeButton' (HashCode=45895697); target element is 'ToolBarToggleButton' (Name='mCustomizeButton'); target property is 'Name' (type 'String')

*Expert Elite*
Alfred.NESWADBA
Posts: 8,880
Registered: ‎06-29-2007
Message 18 of 23 (393 Views)

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

04-23-2012 11:01 PM in reply to: anthonyperks8274

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
-------------------------------------------------------------------------
Contributor
anthonyperks8274
Posts: 25
Registered: ‎01-30-2011
Message 19 of 23 (392 Views)

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

04-23-2012 11:08 PM in reply to: Alfred.NESWADBA

> 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.

 


Contributor
anthonyperks8274
Posts: 25
Registered: ‎01-30-2011
Message 20 of 23 (390 Views)

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

04-23-2012 11:10 PM in reply to: anthonyperks8274

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

 

 

650K long...

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community