Re: COM Interop question in .NET 2.0

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi,

Ok. I am not sure why but it did fix the issue. Obviously y'all know more on
this subject than i do. But i am posting my code below if y'all are still
interested.

[ClassInterface(ClassInterfaceType.None)]
[Guid("8D0240AD-1BBE-4831-8214-39DD46A4A797")]
[ComVisible(true)]
public sealed class TestTool : BaseCommand
{
private IApplication m_app;

public override void OnCreate(object hook)
{
if (hook != null)
{
if (hook is IMxApplication)
{
m_app = (IApplication)hook;
}
}
}

public override void OnClick()
{
IMxDocument mxDoc = (IMxDocument)m_app.Document;
IActiveView activeView = mxDoc.ActiveView;
activeView.Extent = activeView.FullExtent;
activeView.Refresh();
}

public TestTool()
{
base.m_category = "Vish's Test";
base.m_caption = "Full Extent C#";
base.m_message = "Zooms the display to its full extent";
base.m_toolTip = "Full Extent C#";
base.m_name = "Developer Samples_FullExtent C#";

string[] res = GetType().Assembly.GetManifestResourceNames();
if (res.GetLength(0) > 0)
{
base.m_bitmap = new
System.Drawing.Bitmap(GetType().Assembly.GetManifestResourceStream(res[0]));
}
}

#region Component Category Registration

[ComRegisterFunction()]
[ComVisible(false)]
static void RegisterFunction(String regKey)
{
MxCommands.Register(regKey);
}

[ComUnregisterFunction()]
[ComVisible(false)]
static void UnregisterFunction(String regKey)
{
MxCommands.Unregister(regKey);
}

#endregion
}
















"Willy Denoyette [MVP]" wrote:

>
> "Jason Newell" <nospam@xxxxxxxxxx> wrote in message
> news:eCS0FVK5FHA.4036@xxxxxxxxxxxxxxxxxxxxxxx
> > Yeah I know it's always been default because it's bitten me in the
> > rear-end a few times ;-). I honestly didn't think that they would have
> > made a breaking change like that. So the question that still remains, did
> > setting [ComVisible(true)] really solve the problem or was it something
> > else?
> >
> >
> > Jason Newell
> >
> >
>
> Pretty sure it was something else (my guess: missing public on the class).
>
> Willy.
>
>
>
>
>
.



Relevant Pages

  • Re: testing only
    ... but for some reason my posting there never got posted. ... posted 2 messages here to try to fix my problem but they never got posted. ... Prev by Date: ...
    (microsoft.public.windowsxp.general)
  • Re: Require() & GD Library
    ... I gotta start posting mid-day. ... fix my problem tho... ... Prev by Date: ...
    (comp.lang.php)
  • Re: Pocket IE ignores Content-Disposition in Secure HTTP Mode
    ... The fix did not make it into Windows Mobile 5, ... This posting is provided "AS IS" with no warranties, ... Prev by Date: ...
    (microsoft.public.pocketpc.developer)
  • Can no longer connect to inbox
    ... I hope I am posting right, sorry I am new to this. ... Anyways on my Axim X3 I ... to fix it. ... Prev by Date: ...
    (microsoft.public.pocketpc)
  • Re: Another PSA....
    ... Thanks for posting this--it was really ... > and some new Windows Security Center icons? ... > nasties, Smitfraud-c. ... > A REAL fix for Smitfraud-c is not as easy. ...
    (rec.martial-arts)