Kinook Software Forum

Go Back   Kinook Software Forum > Visual Build Professional > [VBP] General Discussion
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 10-23-2003, 01:52 PM
smelly smelly is online now
Registered User
 
Join Date: 10-23-2003
Posts: 4
Question Problem using the VBP automation objects in C#

The sample code in VB6 works like a charm.

''''''''''''''''''''''''''''''''''''''''
Set Builder = New VisBuildSvr.Builder
Set m_app = New VisBuildSvr.Application
Builder.Initialize m_app
m_app.Project.Load "c:\test\test.bld"
Builder.Start vbldStepMain, -1, 0
'''''''''''''''''''''''''''''''''''''''''

The same code in C# doesn’t. Everything compiles and I get no runtime exceptions. However, the build never starts or at least there is no output from the build.

//=======================================
_Application = new ApplicationClass();
_Builder = new BuilderClass();
_Builder.Initialize(_Application);

_Application.Project.Load(@"C:\test\test.bld");

//_Builder.StepStarted +=new
//BuilderEvents_StepStartedEventHandler(_Builder_Ste pStarted);

_Builder.Start(StepTypeEnum.vbldStepMain, -1, 0);
//=======================================


Any help on this would be greatly appreciated.

Thanks!
Reply With Quote
  #2  
Old 10-27-2003, 12:29 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
Attached is a C# port of the VB6 ObjectModel sample that should get you going.
Attached Files
File Type: zip csharpclient.zip (6.4 KB, 1544 views)
Reply With Quote
  #3  
Old 10-27-2003, 02:21 PM
smelly smelly is online now
Registered User
 
Join Date: 10-23-2003
Posts: 4
Question

The ObjectModel sample attached is logically the same as mine. However, this sample code works nicely and mine doesn’t. What I realized is that when I paste my code into a windows form application, it works. My initial proof of concept was done in components. What part of System.Windows.Forms.Form being used by the VisBuild Server objects? Is there a way to make this code work without having to be in a form?

Thanks
Reply With Quote
  #4  
Old 10-27-2003, 03:07 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
The VBP automation objects don't have any dependencies on WinForms, or any part of .NET for that matter. There must be some difference in your component-based code that is resulting in different behavior. I converted my sample to a console app (attached) and it works as expected.
Attached Files
File Type: zip vbp_console.zip (3.3 KB, 1551 views)
Reply With Quote
  #5  
Old 10-27-2003, 04:32 PM
smelly smelly is online now
Registered User
 
Join Date: 10-23-2003
Posts: 4
Ahh ..yes, this runs as expected. However, you changed the build command to sync mode.

m_bld.SyncBuild();

I was using ..

m_bld.Start(StepTypeEnum.vbldStepMain, -1, 0);

Async mode doesn’t seem to work in a console app. Note: I does work in web form. I can use sync mode with events in a worker thread or something to simulate async behavior. I can move on but I'de still like to know if you can get it to work.

Thanks for all the help.

Regards,
Chris
Reply With Quote
  #6  
Old 10-27-2003, 05:52 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
It will work, but in order to use the async version in this scenario, you will need to do some extra work:

1) implement logic to wait until the build has completed.
2) ensure that the builder/app objects remain in existence until they have completed or aborted.
3) (optionally) provide a mechanism for the build to be canceled and take the appropriate steps.
4) ensure that messages continue to get pumped so that events will fire. This could also entail extra work to synchronize multiple threads of execution.

You will still receive build events when using the sync version, so unless you're trying to do separate processing from your component while the build is progressing, that will be the simpler way to go.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



All times are GMT -5. The time now is 03:17 PM.


Copyright © 1999-2023 Kinook Software, Inc.