471,348 Members | 1,358 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,348 software developers and data experts.

Why can't I create a Form in a com-object?

I'm trying to create and display a Form in an inproc COM server using
C# and it is locking up. It's intermittent, but happens more often
than not.

The following code demonstrates the problem - the Form is
unresponsive.

Can anyone explain why this is happening?

====
TestComServerLockup.cs
====
using System.Windows.Forms;
using System.Reflection;
using System.Runtime.InteropServices;

[assembly: AssemblyDescription("TestComServerLockup 1.0 Type
Library")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: Guid("431F88DF-A2B4-4669-841B-ED2A2316676A")]

[Guid("90BBBCF3-81FE-4c82-9A3B-6071E76C6955"),
InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface ITestComServerLockup {
[DispId(1)] void LockUp();
}

[ClassInterface(ClassInterfaceType.None)]
[ProgId("dcc.TestComServerLockup.1")]
[Guid("5C241427-18B7-4b81-A24F-D7791AAB1D4F")]
public class TestComServerLockup : ITestComServerLockup {
public void LockUp() {
Form f = new Form();
f.Name = "Test Form";
f.Text = "Test Form";
f.ShowDialog();
}
}

===
To build:
===
csc /target:library /r:System.Windows.Forms.dll TestComServerLockup.cs
regasm TestComServerLockup.dll /codebase

===
I'm testing it with python + win32 extentions. C++ clients exhibit
the same behavior.
===
python -c "from win32com.client import Dispatch;
Dispatch('dcc.TestComServerLockup.1').LockUp()"
Sep 10 '08 #1
0 772

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Bob Garbados | last post: by
6 posts views Thread by skgolden | last post: by
2 posts views Thread by mpanwar1 | last post: by
1 post views Thread by Ronak mishra | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.