Sparx Systems Forum

Enterprise Architect => General Board => Topic started by: Darren Lock on August 29, 2002, 09:33:45 am

Title: Automation in VB.Net
Post by: Darren Lock on August 29, 2002, 09:33:45 am
How do you create the Interop assembly required to use the EA Automation interface from VB.NET?

Dim x as object
x = CreateObject("EA.Repository") results in 'ActiveX error cannot create object"   ???

The same code from VBScript workds OK.
Title: Re: Automation in VB.Net
Post by: Marc Walter on August 29, 2002, 10:08:54 am
Darren,

The following is working for me:

Public Class EADump
  Public m_Repository As Object
  Private m_rtf As New RTF()

  ' Run the main report
  Public Sub Run(ByVal sInFilename As String, ByVal sOutFilename As String)
     Try
        '  create object
        m_Repository = CreateObject("EA.Repository")
        m_Repository.openfile(sInFilename)

        '  open output file
        m_rtf.OpenFile(sOutFilename)

        '  Dump - this is the report
        DumpModel()

        '  Close things
        m_rtf.CloseFile()

        '  close repository
        m_Repository.exit()
        m_Repository = Nothing
     Catch e As Exception
        m_rtf.WriteParagraph(e.Message)
     End Try
  End Sub
....
Title: Re: Automation in VB.Net
Post by: Darren Lock on August 29, 2002, 10:11:55 am
I now realise that the problem is security related as I am invoking the code from ASP.net!

Rgds, Darren.
Title: Re: Automation in VB.Net
Post by: SonnyBoyIII on August 29, 2002, 11:43:34 am
As a newbie to OOPs, EA, and VB6:

Where do I get the class def for the REPOSITORY?
Title: Re: Automation in VB.Net
Post by: Darren Lock on August 30, 2002, 11:59:58 pm
SonnyBoyIII,

the interface is IDispatch, that is, it is late bound. Therefore you can not reference it in vb6. Because it is late bound you will not be able to type the objects or perform compile time checking. All objects are of type object i.e.

dim objEA as object
set objeEA = CreateObject("EA.Repository")

Hope this helps ~8)~
Title: Re: Automation in VB.Net
Post by: Darren Lock on August 31, 2002, 12:02:29 am
Geoff,

would it be possible to extend Project_Interface.PutDiagramImageToFile to support GIF format?

Rgds, Darren