Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with COM object in vb.net

Status
Not open for further replies.

Sorwen

Technical User
Nov 30, 2002
1,641
US
First, since this is my first time with .net anything I say maybe totally wrong due to a lac of understanding the difference in .net.

That said I'm trying to use a COM object since there is not .net equivalent and get an error. Actually I get the same error with any COM object and it is always the same error.

Error:
System.InvalidOperationException was unhandled
Message="An error occurred creating the form. See Exception.InnerException for details. The error is: Request failed."
Source="WindowsApplication1"
StackTrace:
at WindowsApplication1.My.MyProject.MyForms.Create__Instance__[T](T Instance)
at WindowsApplication1.My.MyProject.MyForms.get_Form1()
at WindowsApplication1.My.MyApplication.OnCreateMainForm()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at WindowsApplication1.My.MyApplication.Main(String[] Args)
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

The "InnerException" says: {"Request failed."}
There seems to be about 50000 parts to the error so let me know if I need to post more.
 
Do you have a COM based control on your form? It looks like the control is failing to load. Take the COM control off of your form and make sure the form loads correctly. If it does, then re-add the control. Open up the "Windows form generation, do not edit" area in the code window. Look for where your object is declared and see if you can find anything odd about it.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
This?

Code:
'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form1))
        Me.AxLabel1 = New AxMSForms.AxLabel
        CType(Me.AxLabel1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'AxLabel1
        '
        Me.AxLabel1.Location = New System.Drawing.Point(215, 19)
        Me.AxLabel1.Name = "AxLabel1"
        Me.AxLabel1.OcxState = CType(resources.GetObject("AxLabel1.OcxState"), System.Windows.Forms.AxHost.State)
        Me.AxLabel1.Size = New System.Drawing.Size(162, 58)
        Me.AxLabel1.TabIndex = 0
        '
        'Form1
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(807, 519)
        Me.Controls.Add(Me.AxLabel1)
        Me.Name = "Form1"
        Me.Text = "Form1"
        CType(Me.AxLabel1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub
It is set there at least. In the refrences it is listed twice. Once with the source as AxInterop.MSForms.dll and then with Interop.MSForms.dll
 
I figured it out. By default our computers are setup to save files to our personal space on the network drive. For whatever reason VS or VB.net doesn't like this and will not build it correctly. I Forced it to save to my C: Drive and it works fine.
 
It does sometimes when the VB first starts, but doesn't say anything when it runs. Also it works fine if the object is .net it is only the com objects that cause it.

-I hate Microsoft!
-Forever and always forward.
 
BTW thanks for the help!

-I hate Microsoft!
-Forever and always forward.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top