Need Help with Revision Manager

Valued Contributor
Valued Contributor

Hallo,i have a little Problem with some Code Snippets from ST3 SDK.

When i look at DocumentClass.Status Property i found this for VB.NET-->...Sub Main() Dim objApplication As RevisionManager.Application = NothingDim objDocument As RevisionManager.Document = NothingTry' Start Revision Manager. objApplication = New RevisionManager.Application  objDocument = objApplication.Open("C:\Part1.par") SelectCase objDocument.Status Case DocumentStatus.igStatusAvailable ' AvailableCase DocumentStatus.igStatusBaselined....Thats work fine.Now i change this to C#

-->....        public string RevMgr()        {            RevisionManager.Application r_application = null;            RevisionManager.Document r_document = null;

            try            {                r_application = new RevisionManager.Application();                r_document = r_application.Open("C:\Part1.par");                r_application.Open(m_filename);                r_application.Quit();            }....

I Have 1 Error in the Code.And I don´t know what´s wrong.At the Line  --> r_application.Open(m_filename); -->The type "objext" can not be implicitly converted to "Revision.Manager.Document".There is already an explicit conversion exists. (may be missing one conversion)

 

Please Help me What´s wrong here.

Thank and regards  Sea

 

 

 

 

Posted by: Stephan Mensing
Post date: 10/2/2011 9:46:23 PM

2 REPLIES

RE: Need Help with Revision Manager

Valued Contributor
Valued Contributor

Hi Sea,

 

the Open method of the RevisionManager.Application object returns an object of type Object. Programming in VB.NET without using Option Strict On (which is Off per default to come closer to VB6) an implicit conversion of the type Object to the type RevisionManager.Document is done by the VB compiler. C# instead behaves as VB.NET would do when using Option Strict On. Then you have to cast/convert the returned type Object to the needed type in code by yourself.

In C# you can do this in 2 ways:

 

1) r_document = (RevisionManager.Document) r_application.Open(...)

or

2) r_document = r_application.Open(...) as RevisionManager.Document

 

The latter will return Null if the conversion of the type fails, whereas the first will throw an exception which should be catched.

 

In VB.NET you equivalently either would use CType(r_application.Open(...), RevisionManager.Document) or TryCast(r_application.Open(...), RevisionManager.Document).

 

Another problem you may run into in you code shown above will be the handling of the string argument "C:\Part1.par".

C# supports C-like special characters. The backslash "\" character will get lost and so your pathname will be invalid! Use either "\\" to get a single "\" interpreted, or simply use @"C:\Part1.par" to protect the whole string from being interpreted for any special characters.

 

 

Posted by: Wolfgang Kunert
Post date: 10/3/2011 10:35:07 PM

RE: Need Help with Revision Manager

Valued Contributor
Valued Contributor

Hello Wolfgang,the first thing has fixed my Problem =).

Thanks and Regard    Sea

 

Posted by: Stephan Mensing
Post date: 10/4/2011 3:44:46 AM