|
No. I have a third party COM API(Neteng.tlb file) which is full COM compliant. I used this COM object in my VB 6 programs by adding a reference to it. When i browse its library thru Object Browser i noticed it has a lot of enumerations(enum in c#) and types(struct in c#) defined. It also exposes one method (NE_AddElement) but this is a MEMBER of a Module.
-----------------------------------------------------------------
It says in Object Browser like...
Sub NE_AddElement(netedit As Long, elatt As ElementAttRec)
Member of NETENG.NETENGAPI
Add the given element using the specified element record.
WHERE NETENGAPI IS...
Module NETENGAPI
Member of NETENG
-----------------------------------------------------------------
That means that this method belongs to the Module not to the class so after i made a reference to the COM i can automatically used the NE_AddElement method defined there and it works fine. My VB 6 program can recognized the method.
Now i tried using the same COM API (Neteng.tlb) inside a VB.Net/C#. I made a reference to that COM API (as a COM object) inside my VS.NET IDE using the COM portion and it goes fine. I was successful at doing that but when i compile the code it RETURNED a compilation error saying:
----------
The name 'NE_AddElement' does not exist in the class "myclass name here"(CS0103)
----------
Why is that it can't recognized the NE_AddElement method though i have successfully Add a Reference to its COM? When i checked the equivalent InterOp assembly created after making the referencing i noticed it only exposes the class level enumerations and class level structs. Members of NETENGAPI (a Module) like the method NE_AddElement were not exposed. In VB 6 it can recognized the method as member of the NETENGAPI module. Can someone tell me how My VB.NET/C# program can fully recognized and in doing so used the NE_AddElement method!!!! Tnx in advanced!!!
|
|
|
|
|
Have you opened your library (which, btw, isn't the TLB file - that's only the typelib which contains information about the COM objects in your library) in depends.exe to find the exported function? It may be mangled using C++ decoration.
I'm curious why you can't create an RCW, though. If it is a COM control and contains a typelib (either as an external file or embedded in the .rsrc section of the executable) you can run tlbimp.exe on it (or the external .tlb file). If that doesn't seem to work, you should open the DLL in VS.NET to view the resources and see if the typelib uses an ID other than 0, which using tlbimp.exe you can specify the name of the DLL along with the ID for the embedded typelib like so:
tlbimp.exe MyLib.dll/1 If this also contains an ActiveX control, you can use aximp.exe to create an interop assembly that contains a control/controls that derive from AxHost , which derives from Control an can be used in a container control.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Its not a COM control its just a COM file(neteng.tlb). I noticed there's two other file in the same installation directory of that DLL (neteng.lib and neteng_CB.lib). How are this files related to neteng.tlb COM file?Which file should i import using tlbimp.exe?Importing neteng.lib or neteng_CB.lib via tlbimp says its not a valid type library. But i can import neteng.tlb and and it can create an assembly. This is exactly the same COM i used in my vb 6 program. I noticed also that the interop assembly created for the COM doesnt show any existence of a class. Only the namespace name, structs and enums are shown. The module and its methods were not exposed. So how would i be able to call the methods of the module as part of the created interop assembly if in the first place i can't see them present in the created assembly? Many Thanx!
|
|
|
|
|
As I said in my reply, you use tlbimp.exe on the typelib - either an external .tlb or a typelib as a resource in an execute. A typelib, BTW, contains no executable code. There is still a COM server somewhere on your server that implements the interfaces that the typelib describes. That's all typelibs are - information about COM objects implemented in an executable (the COM server) that languages and frameworks can use to discover type information at design-time and compile-time.
Even VB only uses the typelib for type information. At runtime, the CLSIDs (class IDs) are used to find the executed and its class factory creates an instance of the COM object with that CLSID (this is a very basic overview). If tlbimp.exe doesn't see a certain object or method, it's probably because it violates some rules of COM and cannot be imported.
You should familiarize yourself with COM since VB hides all that from you, and run oleview.exe (part of the Platform SDK tools, which is installed by default with Visual Studio) passing the path to your typelib as the sole parameter. This will show you the IDL. Take a look at the method and, if you want, post back the method signature in this thread.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I'm just trying to toggly between two check boxes a draw x values and a draw y values. I found this code but I'm getting a stack overflow error when I click on the check box....
private void XvaluescheckBox_CheckedChanged(object sender, System.EventArgs e)
{
// Toggle boolean
switch(this.XvaluescheckBox.CheckState)
{
case CheckState.Checked:
// Code for checked state.
this.m_bDrawXValues = false;
this.XvaluescheckBox.CheckState = CheckState.Unchecked;
break;
case CheckState.Unchecked:
// Code for unchecked state.
this.m_bDrawXValues = true;
this.XvaluescheckBox.CheckState = CheckState.Checked;
break;
case CheckState.Indeterminate:
// Code for indeterminate state.
break;
}
}
private void YvaluescheckBox_CheckedChanged(object sender, System.EventArgs e)
{
// Toggle boolean
switch(this.YvaluescheckBox.CheckState)
{
case CheckState.Checked:
// Code for checked state.
this.m_bDrawXValues = true;
this.YvaluescheckBox.CheckState = CheckState.Unchecked;
break;
case CheckState.Unchecked:
// Code for unchecked state.
this.m_bDrawXValues = false;
this.YvaluescheckBox.CheckState = CheckState.Checked;
break;
case CheckState.Indeterminate:
// Code for indeterminate state.
break;
}
}
|
|
|
|
|
You're changin the check state of the checkbox inside the CheckChanged event handler -- i.e. as soon as your check state has changed, your function gets called. Your function then changes the check state, once again calling your function, which goes forever in a loop until the stack overflows.
If you need to change the check state of the checkbox inside the check change function, unhook the event handler first. Try something like
private void YvaluescheckBox_CheckedChanged(object sender, System.EventArgs e)
{
switch(this.YvaluescheckBox.CheckState)
{
case CheckState.Checked:
this.m_bDrawXValues = true;
this.YvaluescheckBox.CheckChanged -= new EventHandler(YvaluescheckBox_CheckedChanged);
this.YvaluescheckBox.CheckState = CheckState.Unchecked;
this.YvaluescheckBox.CheckChanged += new EventHandler(YvaluescheckBox_CheckedChanged);
break;
Or, just don't set the check state of the check box inside your check state change event handler like you're doing there.
---------------------------
He who knows that enough is enough will always have enough.
-Lao Tsu
|
|
|
|
|
If you have two (or more) checked buttons and only one of them should be set at a time, then you should use option buttons.
I see dumb people
|
|
|
|
|
So do I, all the time!
I used the radio buttons, those work nicely..Doh!
|
|
|
|
|
Isnt CheckedChanged called after the checkboxes state is changed? Basically, your recieving the event, and changing a property of the checkbox, that causes the event to be fired again, so its a vicious circle.
Instead, try:
private void XvaluescheckBox_CheckedChanged(object sender, System.EventArgs e)
{
this.m_bDrawXValues = this.XvaluescheckBox.Checked;
}
private void YvaluescheckBox_CheckedChanged(object sender, System.EventArgs e)
{
this.m_bDrawYValues = this.YvaluescheckBox.Checked;
}
I havent tested it, but that should work. Strictly speaking, you dont even need the m_bDrawXValues and m_bDrawYValues variables, you can use the Checked property of the checkboxes.
To those who didn't make it, we will remember you. To those who did is back. - Megan Forbes in Black FridayAnother Post by NnamdiOnyeyiri
|
|
|
|
|
Hi
I made an application with Crystal dependecie. When I made the Setup Project, this detect it. And add a crystal packet, but when I build the project, and try to install this in another PC without Crystal assembly, the install begins but in the middle stop with a warning about a miss assembly, I imagine this miss assembly is Crystal, cuz I only use .NET and Crystal assembly, anyone else.
What can I do??
Thanks.
----
hxxbin
|
|
|
|
|
|
Thanks I'm lookin' the article about in MSDN.
----
hxxbin
|
|
|
|
|
|
XCOPY won't work with Crystal Reports. As the documentation I gave a link for explains, the regwiz*.msm merge module needs the license key. It uses this to register it in the registry or in a file somewhere (I haven't looked, so I don't know at this point). You must use an installer so that the Crystal Reports runtime is registered correctly.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Welcome to the Crystal Reports mini-hell ...
When you install you application on a client machine, ... the user presses to get his fancy report, and Crystal Reports throws you this exception
cannot find keycodev2.dll, or invalid keycode
In order to avoid this error, you need to add to your installation set, the following msm’s ( in your Visual Studio Installer you will find the option “add modules”, and it will point you automatically to the right folder where the MSM’s are there). Then add the following msm’s:
· regwiz ( or regwiz2003 something like that in Vstudio 2003), there in the “properties” of that MSM, you will find (after search a bit), an option called “License Key”, there you have to include the license key of your Crystal reports ( go to Visual Studio, Help Menu, about box... there you can find your Creports ID Key).
· You need to include two more msm’s, one about STL and another about ATL ( you will find them in the same place).
Have fun...
|
|
|
|
|
Je je,
No me había dado cuenta de que eras de Méjico ! , yo soy de España ( Málaga al sur).
Saludos !
Braulio
|
|
|
|
|
Sip, Mexicano, aka de Guadalajara Saludos a la gente hispana!
----
hxxbin
|
|
|
|
|
I still can't make this works. I read the article, and added three more modules, to the regwiz2003 module I added the licence code. But it still doesn't work . The message I got display this:
Unabled to get installer types in the c:\....\.exe assembly. -->
One or more of the types in the assembly unable to load.
----
hxxbin
|
|
|
|
|
Finally I got this work. I make a dummy project with the CR modules and then just a XCOPY with my project, and works
I can relax me this weekend
----
hxxbin
|
|
|
|
|
Greetings All,
I have a DataGrid bound to a DataTable. A particular column in my DataTable contains names in all uppercase. I would like to present this data in the grid capitalized (first character of each word uppercase the rest lower). What is the best way to achieve this?
Many Thanks,
Bitwise
|
|
|
|
|
Well, you could always NOT store them all in caps. :P
The best way is to use format specifiers, but you'll need to create a custom IFormatProvider to provide formatting for strings. Read my article, Custom String Formatting in .NET[^]. It gives you links to additional information.
Then, you must define table and column styles. See the DataGrid.TableStyles property documentation in the .NET Framework SDK for more information and an example.
Finally, on the DataGridTextBoxColumn bound to your column in question, assign the FormatInfo property to your IFormatProvider you created from the info above, and set the Format property to the specifier (if any).
For instance, you could create an IFormatProvider that when passed to various formatting functions calls creates a new string with the first character of each word capitalized and the rest of the characters in lower case. You could do ths many different ways.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Do you think I can convert a string of binary numbers, say, "110" to integers (should equals 6) using the IFormatProvider? Thanks
|
|
|
|
|
Yes, and if you look at my article I already go the other way (going back is trivial using the BitConverter ).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Greetings,
Thank you for the reply Heath! Great info! I have implemented the IFormatProvider and ICustomFormatter interfaces in a StringFormatInfo class as per your article. Works like a charm when tested with a String.Format call.
My problem is that my grid seems to be ignoring my DataGridTextBoxColumn.FormatInfo setting . Using breakpoints I see that I never enter the StringFormatInfo code. The indifference seems to be based on the underlying DataColumn's type ... which is System.String . If I set the .FormatInfo property for another DataGridTextBoxColumn in the grid, with an underlying System.Int32 DataType, the StringFormatInfo breakpoint is reached.
Thank You,
Bitwise
|
|
|
|
|
Interesting. Looking at the IL, I see that a type must implement IFormattable , which the String class does not! That's not good, nor typical.
There seems to be another way, though. You can set the PropertyDescriptor property using a PropertyDescriptor that describes your string. The set accessor for PropertyDescrptor uses that information to get a TypeConverter for your string. You can use this TypeConverter instead of the formatter, or use them in conjunction with each other (i.e., the TypeConverter could use the formatter you've created). It's a cludge, but it looks like it'd work.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|