.NET

Reply
Valued Mentor
340 Posts
53 Kudos
Registered: ‎05-12-2009
Post 11 of 19

Re: Document CloseAndDiscard In 2013

03-08-2013 02:24 PM in reply to: matus.brlit

Not sure what your asking

 

Imports System
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.ApplicationServices.DocumentExtension

<Assembly: CommandClass(GetType(AutoCAD_VB_plug_in1.MyCommands))> 
Namespace AutoCAD_VB_plug_in1

    Public Class MyCommands


        <CommandMethod("MyCommand")> _
        Public Sub MyCommand()
            Dim doc As Document = Application.DocumentManager.MdiActiveDocument
            doc.CloseAndDiscard()

        End Sub


    End Class

End Namespace

 

You can also find your answers @ TheSwamp
Valued Mentor
370 Posts
175 Kudos
Registered: ‎05-06-2012
Post 12 of 19

Re: Document CloseAndDiscard In 2013

03-08-2013 03:59 PM in reply to: matus.brlit

The doc you quote relate to defining/implementing extension methods in VB, not consumign them from VB.

 

There does seem to be a problem with consumig those methods as extension methods in VB.NET, and it may have something to do with the fact that both containing type and the methods themselves require the ExtensionAttribute.

 

Valued Mentor
370 Posts
175 Kudos
Registered: ‎05-06-2012
Post 13 of 19

Re: Document CloseAndDiscard In 2013

03-08-2013 04:04 PM in reply to: matus.brlit

matus.brlit wrote:

I know that, Alexander. I was asking about the module for VB.


 

There is no module to import.

 

You are looking at docs that relate to defining extension methods in VB.NET, not consuming extension methods from an assembly.

 

You should only have to import the namespace containing the type that exposes the extension methods, but as I mentioned in my other reply, there seems to be a problem there, as when I tried with the required assembly reference and namespace import, the VB code compiler couldn't find the extension method.

 

 

Mentor
247 Posts
6 Kudos
Registered: ‎03-11-2008
Post 14 of 19

Re: Document CloseAndDiscard In 2013

03-11-2013 12:03 AM in reply to: DiningPhilosopher

@DiningPhilosopher: Exactly, that's what I am trying to say. It doesn't work as extension method for VB. I quoted the docs for defining the extension method, because I wanted to point out, that there might be a problem. If you reference the same class from VB and C# it's not compatible.

 

@Jeff: This is what I would expect, but it doesn't work for me.

Valued Mentor
340 Posts
53 Kudos
Registered: ‎05-12-2009
Post 15 of 19

Re: Document CloseAndDiscard In 2013

03-11-2013 06:35 AM in reply to: matus.brlit

In the last example,

CloseAndDiscard does not show up in intellisense but it does build for me.

You can also find your answers @ TheSwamp
Mentor
247 Posts
6 Kudos
Registered: ‎03-11-2008
Post 16 of 19

Re: Document CloseAndDiscard In 2013

03-12-2013 12:15 AM in reply to: jeff

@Jeff: Thanks, it's really just missing intellisense that confused me.

Valued Mentor
340 Posts
53 Kudos
Registered: ‎05-12-2009
Post 17 of 19

Re: Document CloseAndDiscard In 2013

03-12-2013 10:23 AM in reply to: matus.brlit

In a VB project if I reference a fully managed assembly written in C# with extension methods all I have to do is import the namespace and shows up in intellisense and what not.

Don't know?

You can also find your answers @ TheSwamp
Mentor
247 Posts
6 Kudos
Registered: ‎03-11-2008
Post 18 of 19

Re: Document CloseAndDiscard In 2013

03-13-2013 12:09 AM in reply to: jeff

Do you mean, that it usually works? Or that it works for you with this particular case too?

Valued Mentor
340 Posts
53 Kudos
Registered: ‎05-12-2009
Post 19 of 19

Re: Document CloseAndDiscard In 2013

03-13-2013 04:41 AM in reply to: matus.brlit

Sorry,

I just was referring to a library of extension methods written in C# that I referenced into new VB project to test quickly.

You can also find your answers @ TheSwamp
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post