Member of a .NET class is empty in the VB6 object browser - vb.net

At the moment I´m trying tests on the interoperability of VB6 and .NET using COM.
I have followed this simple example to call a .NET component from COM.
https://msdn.microsoft.com/en-us/library/ms973802.aspx
The DLL is registered and the assembly was "succesfully added to the cache". However when I take a look into the object browser of VB6 I can only see methods of the interface and not of the actual class. COM is set on visible and the correct path for the KeyFile, are both in the AssemblyInfo.vb file. The .NET Class+Interface looks like this:
Public Interface iTemperature
'some properties and functions
End Interface
Public Class NET_Temperature
Implements iTemperature
'some implemented public properties and functions
End Class
When I try to run the following Code:
Set moTempClass = New PhysServer2.NET_Temperature
Set moTemp = moTempClass
I´m getting the well known 429-runtime error, saying that creating an object through an Active-X-component does not work. There is a lot of information on the internet regarding this error with unregistered DLL/TLB, but I´m more concerned about the fact that only the methods and properties of the interface are shown in the object browser and not the implemented methods/properties of the interface - the class. How can I fix this Error and make the methods in my class sort of visible to COM and the object browser?

Related

Show Base Class throws error if base class is generic and in a class library

Say I have a class library project (Library) which contains a class of:
Public Class SomeClass(Of TTypeA, TTypeB)
Then, in another project UIProject in a different solution, I define a class that is derived from (inherits) SomeClass:
Imports Library
Public Class SomeDerivedClass
Inherits SomeClass(Of String, Boolean)
I have included Library.pdb and Library.xml alongside Library.dll (in the same folder) when I added the class libary reference to the UIProject.
Now, In UIProject I create a ClassDiagram (ClassDiagram1.cd), and add in the SomeClass class. So far so good.
The next step is to right-click on SomeClass in the diagram, and select "Show Base Class" from the dropdown. At this point, I am given the error:
Error HRESULT E_FAIL has been returned from a call to a COM
component.
If I do the same but for a non-generic version of SomeClass, then SomeClass is included in the class diagram, no problem.
No errors show up in ActivityLog.xml; nor in the Windows Event Viewer.
Is this a bug in Visual Studio (in which case I'll report it); or am I doing something wrong (and if so are there any other error logs or traces I can do to narrow down the issue further)?
The answer seems to be that COM does not work with generic types; and that it works in VS2017.

How to add a property page to DirectShow filter

I have written an DirectShow-Filter *.ax to integrate a Hardware (Camera). All works fine with my filter.ax and there Transport Images to Skype success.
Now I am want to integrate a Dialog to handle the camera-options with UI.
In my Filter.ax is calling the function QueryInterface(REFIID riid, void **ppv)
when riid == IID_ISpecifyPropertyPages
I am have seen that the Dialog must be in a other DLL like Com ?
My try to open the Dialog directly works, but no windows Messages are incoming.
I must also write an MFC Dll they is starting by PropertyPage IIID ? My Propertypage is a large MFC Controles TabControl with some items. I can see it if i start the filter from MFC Test app. AfxInit I can't execute. (Wrong Lib versions I must use the directshow baseclass(knowledge example)
I don't now why my Dialog got no Messages, what is the right way ?
You don't need to implement a property page in a separate DLL (even though it is a possible).
DirectShow filter property pages are regular COM property pages implemented using ISpecifyPropertyPages. Property pages are separate COM objects implementing well known interfaces like IPropertyPage.
Windows SDK Ezrgb24 sample shows how to implement a simple transform filter and also features a property page (CEZrgb24Properties class). It should be a good start for a property page implementation for your filter.
If you prefer to implement the property page in a separate DLL, a typical way is to define a shared COM interface, the filter would implement it and reference the property page by its CLSID, the property page would query this interface from the filter instance and use it for configuration actions.

How does VB.NET execute a non-shared method without an instance? [duplicate]

I'm just curious to know that there is the (Name) property, which represents the name of the Form class. This property is used within the namespace to uniquely identify the class that the Form is an instance of and, in the case of Visual Basic, is used to access the default instance of the form.
Now where this Default Instance come from, why can't C# have a equivalent method to this.
Also for example to show a form in C# we do something like this:
// Only method
Form1 frm = new Form1();
frm.Show();
But in VB.Net we have both ways to do it:
' First common method
Form1.Show()
' Second method
Dim frm As New Form1()
frm.Show()
My question comes from this first method. What is this Form1, is it an instance of Form1 or the Form1 class itself? Now as I mentioned above the Form name is the Default instance in VB.Net. But we also know that Form1 is a class defined in Designer so how can the names be same for both the Instance and class name?
If Form1 is a class then there is no (Static\Shared) method named Show().
So where does this method come from?
What difference they have in the generated IL?
And finally why can't C# have an equivalent of this?
This was added back to the language in the version of VB.NET that came with VS2005. By popular demand, VB6 programmers had a hard time with seeing the difference between a type and a reference to an object of that type. Form1 vs frm in your snippet. There's history for that, VB didn't get classes until VB4 while forms go all the way back to VB1. This is otherwise quite crippling to the programmer's mind, understanding that difference is very important to get a shot at writing effective object oriented code. A big part of the reason that C# doesn't have this.
You can get this back in C# as well, albeit that it won't be quite so clean because C# doesn't allow adding properties and methods to the global namespace like VB.NET does. You can add a bit of glue to your form code, like this:
public partial class Form2 : Form {
[ThreadStatic] private static Form2 instance;
public Form2() {
InitializeComponent();
instance = this;
}
public static Form2 Instance {
get {
if (instance == null) {
instance = new Form2();
instance.FormClosed += delegate { instance = null; };
}
return instance;
}
}
}
You can now use Form2.Instance in your code, just like you could use Form2 in VB.NET. The code in the if statement of the property getter should be moved into its own private method to make it efficient, I left it this way for clarity.
Incidentally, the [ThreadStatic] attribute in that snippet is what has made many VB.NET programmers give up threading in utter despair. A problem when the abstraction is leaky. You are really better off not doing this at all.
VB is adding a load of code into your project behind your back, basically.
The easiest way to see what's going on is to build a minimal project and look at it with Reflector. I've just created a new WinForms app with VB and added this class:
Public Class OtherClass
Public Sub Foo()
Form1.Show()
End Sub
End Class
The compiled code for Foo looks like this when decompiled as C#:
public void Foo()
{
MyProject.Forms.Form1.Show();
}
MyProject.Forms is a property in the generated MyProject class, of type MyForms. When you start diving into this you see quite large amounts of generated code in there.
C# could do all of this, of course - but it doesn't typically have a history of doing quite as much behind your back. It builds extra methods and types for things like anonymous types, iterator blocks, lambda expressions etc - but not in quite the same way that VB does here. All the code that C# builds corresponds to source code that you've written - just cleverly transformed.
There are arguments for both approaches, of course. Personally I prefer the C# approach, but that's probably no surprise. I don't see why there should be a way of accessing an instance of a form as if it was a singleton but only for forms... I like the language to work the same way whether I'm using GUI classes or anything else, basically.

RealProxy issues with compile time

I have a class MyProxy derived from RealProxy and implemented the bare minimum of Invoke to silence compile time errors. I inherit from MyProxy a custom class TabControl2 which itself wraps (ie: decorator) an TabControl.
I wish to call/intercept TabControl methods via the decorator - implementing everything myself as a learning exercize.
I understood the Invoke() of RealProxy would allow runtime interception of undefined methods in the decorator and call Invoke() with details of the invocation, such as method and arguments; thus allowing me to optionally invoke the original "decorated" object
I have googled for examples found many in C# and ported much of the code over to vb.
This particular bit of code is killing me:
Dim tabCtrlGeneric As TabControl = New TabControl()
Dim tabCtrlDecorator As TabControl = CType(New TabControlReorder(tabCtrlGeneric), TabControl)
Is giving me a compile time errors about type...not sure why?

Flex Interface method createAutomationIDPartWithRequiredProperties error

I'm currently creating a class that extends UIComponent in Flex 3, but when the flash builder try to compile show me some errors
1044: Interface method createAutomationIDPartWithRequiredProperties in namespace mx.automation:IAutomationObject not implemented by class components:ArtWorkImage
1044: Interface method get automationEnabled in namespace mx.automation:IAutomationObject not implemented by class com.senocular.display:TransformTool
I see that UIComponent implements this interface, but I had never had this error before, I'm assuming UIComponent should made this implementation by default, so it should be something else, I already try to recreate the project or clean it, with no result, can someone please point me how maybe this can be fix, thanks for your help
oh btw I had this project before in flex builder, exported as a FXP and imported in Flash Builder, thanks!
All UI objects use an Automation delegate to handle implementation of the automation interface. Each UIComponent has a specific automation delegate registered with the Automation Framework. These automation delegate implementations are injected into the object by the Automation framework when the object is created according to the class name of the object.
For example:
UIComponent <- UIComponentAutomationImpl
ToolTip <- ToolTipAutomationImpl
DateChooser <- DateChooserAutomationImpl
Normally if you subclass a component you should inherit the Automation Implementation. However depending upon how the instances of the object are being created the automation framework may not be able to resolve the class name to the appropriate super class. In this case you may need to take additional steps to get the automation implementation into your class.
If you want your class to automatically be injected with a particulary automation implementation you should call the static registerDelegateClass method on the mx.automation.Automation class.
import mx.automation.*
Automation.registerDelegateClass(com.foo.bar.ArtWorkImage, mx.automation.delelegates.core.UIComponentAutomationImpl);
Alternatively you could directly implement the IAutomationObject methods in your UIComponent or create your own delegate class and instantiate and "inject" it into your class in its' constructor thereby by passing the Automation framework.
Here are few links that might help you understand the automation framework:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/automation/Automation.html
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/automation/delegates/core/UIComponentAutomationImpl.html
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/automation/package-detail.html