#1
|
|||
|
|||
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! |
#2
|
|||
|
|||
Attached is a C# port of the VB6 ObjectModel sample that should get you going.
|
#3
|
|||
|
|||
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 |
#4
|
|||
|
|||
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.
|
#5
|
|||
|
|||
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 |
#6
|
|||
|
|||
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. |
Thread Tools | |
Display Modes | Rate This Thread |
|
|