|
The trouble is that Exchange 5.5 is regarded by MS as legacy, and MSDN itself now almost only references Exchange 2000[^]+ articles. I guess you need older MSDN.
I would use CDO[^] objects (they exist prior Exchange 2000) or DAO depending on what you like. In fact, you have a couple of COM objects that you just reference in your ASP.NET project before start using them.
For ActiveDirectory, that's the same. There's a bunch of ADSI COM objects.
Good luck!
sometimes it helps to look at the IL generated code
a MS guy on develop.com "answering" .NET issues
|
|
|
|
|
Hi,
I am trying convert following VB Code to c#.
VB CODE
--------------
Set oLogonCtrl = CreateObject("SAP.Logoncontrol.1")
Set oBAPICtrl.Connection = oLogonCtrl.NewConnection
oBAPICtrl.Connection.System = "00"
oBAPICtrl.Connection.MessageServer = txtSysMessageServer
oBAPICtrl.Connection.GroupName = txtSysGroupName
C# CODE
________
SAPBAPIControlLib.SAPBAPIControl oBapiControl=new SAPBAPIControlLib.SAPBAPIControl();
SAPLogonCtrl.SAPLogonControl oLogonCtrl=new SAPLogonCtrl.SAPLogonControl();
oBapiControl.Connection=oLogonCtrl.NewConnection();
oBapiControl.Connection.System="00";
The SAPBAPIControl is a COM control I am using in C#. In visual
Studio I am referencing this and VS creates wrapper for the COM
control.
Till oBapiControl.Connection=oLogonCtrl.NewConnection() I have
no problem. But when I try oBapiControl.Connection.System="00"
I get message "'object' does not contain a definition for 'System'".
Any Ideas why this must be happening ?
Thanks in Advance
Ravi H R
|
|
|
|
|
Looks like the System property is badly interoped.
I guess all problems you have are at compiling-time. You haven't run anything yet ?
You have probably dropped the SAP control from the toolbox to your Form (or you have added a reference by browsing the actual dll/exe COM object). Let's make sure the signature is right :
- using intellisense, what's brought to you when you type oBapiControl.Connection. ? Is there any System property available ?
- does it change if you add a using SAPBAPIControlLib; statement ?
- when adding a reference from a COM object, the IDE automatically imports the type-library. In addition, if this control is an ActiveX, it creates an interop ActiveX layer as well. Those 2 files are in the /obj directory. It may be useful to have a look inside, using a disassembler such like Anakrino[^].
sometimes it helps to look at the IL generated code
a MS guy on develop.com "answering" .NET issues
|
|
|
|
|
Thanks for your response Stephene,
First When I type oBapiControl.Connection. I see following
methods "Equals","GetHashCode","GetType" and "ToString".
I donot see any other properties or methods.
I added the control through Project-> Add reference->COM. I could see the control here. When I selected the component,
I got message "Couldnot find primary interop assembly...
would you like to have a wrapper generated ?" I said yes.
After this I could see the components is solutions explorer(SE). I saw additional thing in SE by name "stdole".
Using SAPBAPIControlLib didnot have any effect.
I see 2 dlls in obj folder "Interop.SAPBAPIControlLib_1_2.dll" and "Interop.SAPLogonCtrl_1_1.dll"
what could be wrong ?
I will wait for your response
Thanks & Regards
Ravi H R
|
|
|
|
|
RAVI H R wrote:
I see following
methods "Equals","GetHashCode","GetType" and "ToString".
I donot see any other properties or methods.
This means that appropriate SAP references are missing. What you said next confirms it.
RAVI H R wrote:
After this I could see the components is solutions explorer(SE). I saw additional thing in SE by name "stdole".
Now you probably see the names SAPBAPIControlLib_1_2 and SAPLogonCtrl_1_1 in the reference. In your file can you type SAPBAPIControlLib_1_2. , what's brought up by intellisense ?
RAVI H R wrote:
what could be wrong ?
My crystal ball sees a marshaling problem, for instance the System property passed as a VARIANT** instead of a BSTR, or something like that. But what I say is already beyond the simple thing : you should first be able to see the System property in the intellisense dropdown box.
You may send me these 2 files, so I give a look.
sometimes it helps to look at the IL generated code
a MS guy on develop.com "answering" .NET issues
|
|
|
|
|
Hi Stephane,
You have written
Now you probably see the names SAPBAPIControlLib_1_2 and SAPLogonCtrl_1_1 in the reference. In your file can you type SAPBAPIControlLib_1_2., what's brought up by intellisense ?
I see in reference
SAPBAPIControlLib and SAPLogonCtrl.
Intellisense doen't show anything when i type SAPBAPIControlLib_1_2.
I tried one more thing
C# CODE
-----------
APLogonCtrl.SAPLogonControl oLogonControl=new SAPLogonCtrl.SAPLogonControl();
//SAPBAPIControlLib.SAPBAPIControl conn=new SAPBAPIControlLib.SAPBAPIControl();
SAPLogonCtrl.Connection conn=new SAPLogonCtrl.Connection();
conn=(SAPLogonCtrl.Connection)(oLogonControl.NewConnection());
conn.Client="500";
conn.User="";
conn.Password="";
conn.Language="en";
conn.ApplicationServer="localhost";
conn.System="00";
bool bRtcd=conn.Logon(0,false);
if(bRtcd!=true)
Console.WriteLine("bRtcd="+bRtcd.ToString());
I get invalid typecast the code compiles when I execute I get Invalid Typecast exception for conn=(SAPLogonCtrl.Connection)(oLogonControl.NewConnection()). The oLogonControl.NewConnection() returns object.
I will send across the two dlls through email
Thanks
Regards
Ravi H R
|
|
|
|
|
I need to read a binary file into a ushort array. The file was created with another app, and just consists of two bytes per ushort (big endian). FileStream.Read will get the bytes in OK - as bytes. I'd like to read them in directly to ushort. Sounds simple. Is it?
|
|
|
|
|
David Williams wrote:
I'd like to read them in directly to ushort. Sounds simple. Is it?
It does sound simple, especially if you see how a mapping of the will look. Unfortunately there is no direct way.
I would make a class deriving from FileStream and overload the Read method with some thing like this:
public ushort ReadUShort()
{
return (ushort) ((ReadByte() << 8) + ReadByte());
}
public int Read( ushort[] buffer, int offset, int length)
{
Position += offset;
int i = 0;
if (CanRead) {
for (; i < length; i++)
{
buffer[i] = ReadUShort();
}
}
return i;
}
You can try that, someone might have an easier idea
Hope this helps
Give them a chance! Do it for the kittens, dear God, the kittens!
As seen on MS File Transfer: Please enter an integer between 1 and 2.
|
|
|
|
|
Yep. This works, and you do have the bit ops correct. Thanks
|
|
|
|
|
David Williams wrote:
Yep. This works, and you do have the bit ops correct. Thanks
Cool
I remembered I saw something like << 16 for Int32 , so the guess was made accordingly hehe.
However, the way I did it may not be (and probably is not) efficient.
You maybe use the Encoding class (UTF8 and Unicode (BigEndian) ) in a reverse fashion, it sounds a lot like you are dealing with a UTF8 to Unicode(BigEndian) conversion.
Alternatively, the more "dangerous" way is to use a bit of marshalling, remember what I said about the way the data is laid out in memory. So make a small converter.
ushort[] ConvertToUShortArray( byte[] array)
{
int size = Marshal.SizeOf(typeof(byte)) * array.Length;
ushort[] output = new ushort[array.Length/2];
IntPtr ptr = Marshal.AllocHGlobal(size);
Marshal.Copy(array, 0, ptr, array.Length);
Marshal.PtrToStructure(ptr, output);
Marshal.FreeHGlobal(ptr);
return (ushort[])output;
}
Ugly!! but efficient
Hope this helps
Give them a chance! Do it for the kittens, dear God, the kittens!
As seen on MS File Transfer: Please enter an integer between 1 and 2.
|
|
|
|
|
I have big problem for making class deriving from FileStream or BinaryReader
I need to read a binary file into a some struct. Pleas help.
|
|
|
|
|
Check out BinaryFormatter.Deserialize
I'm pretty sure that will do the job for you.
Paul
|
|
|
|
|
The formatters are used for serializing and deserializing classes/structures to and from streams. They also write and read an extra header that tells the runtime what type of object is in the stream and what name (if any) it has.
To sum it up; the formatter can't be used unless it was used to create the data.
James
Sig code stolen from David Wulff
|
|
|
|
|
Daaamn! That's very cool... but slightly annoying if it's not what you want
Paul
|
|
|
|
|
Yeah, I tried the deserialize and found it needed a header. Just to see what it needed, I serialized a 10 byte binary file and found the binary formatter put 28 bytes of header up front. Oh, well. lippie's solution works. Thanks for the response, though.;)
|
|
|
|
|
I think the easiest thing to do is to use a BinaryReader, and just call ReadUInt16().
|
|
|
|
|
So it is simple
Give them a chance! Do it for the kittens, dear God, the kittens!
As seen on MS File Transfer: Please enter an integer between 1 and 2.
|
|
|
|
|
No, not simple. Gunnerson's BinaryReader works, but for little endian, not big.
|
|
|
|
|
This works for little endian. Will it work for big endian if I call it thus: 16IntURead()
|
|
|
|
|
I think the answer to that would be "no". You'd need to call ReadUInt16FlipFlopBytes()...
If you need to do this, you can either do the byte flip yourself, or you may be able to use the IPAddress class.
|
|
|
|
|
While Winform application and other applications(such as words, excel, etc) are running in user's desk top, I want when new message comes within winform application, no matter the status of Winform application is (minimized window, inactive,etc), the message form shows on the top of other applications they are running. It is similar to outlook schedual warnings, when it is the warning time, it comes out to draw your attention away from other things you are working on. Is it possible to achieve it?
Thanks
|
|
|
|
|
I hope you will never achieve this. That's annoying sh*t. ( (
Why not use a blinking systray instead ?
sometimes it helps to look at the IL generated code
a MS guy on develop.com "answering" .NET issues
|
|
|
|
|
StephaneRodriguez wrote:
That's annoying sh*t
Agree!
Give them a chance! Do it for the kittens, dear God, the kittens!
As seen on MS File Transfer: Please enter an integer between 1 and 2.
|
|
|
|
|
To anybody:
Hi. I'm trying to get all items of the Internet Explorer's ComboBox through a C# source code. So far I've got the handles to the child windows. But how to extract all items? Must I open the combobox to fetch all urls? There is no result on my efforts.
I used a SendMessage and got no error messages. Where is my fault?
Is anybody out there to help me a little?
|
|
|
|
|
Not a C# topic. Ask WIN32 gurus. IMHO, there is nothing particular about IE combo-boxes, except they are subclassed (seen with Spy++).
sometimes it helps to look at the IL generated code
a MS guy on develop.com "answering" .NET issues
|
|
|
|