|
Anything in the VisualBasic namespace is legacy rubbish and should be avoided.
Console.WriteLine((char)(65));
This prints out 'A', so a cast to char will work just fine. You're building a string with multiple null delimiters, from the look of it ? The fact you're only putting one null in makes it an ANSI string, so this should work just fine.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Ok so the Rest of that string can be Eliminated totally???
with like:: headerReturn = Name(char(65)); ?? what about the rest of it
Strings.Chr(int.Parse("&H" + PacketType)) + new string(Strings.Chr(0), 8) + pck;
I understand what your saying,I'm not putting Visual Basic in my C# code by any means...I'm just trying to Convert that string into a complete string for C#...I'm fairly new to working with Char in C#...
or would it be something along this line::
headerReturn = Name + (char(65)) + (char(int.Parse("&H" + PacketType))) + pck; ????
So you get the Whole picture here is the Entire Block of Code::
public static string Header( string PacketType, string pck ) <br />
{<br />
<br />
string headerReturn = null;<br />
short i = 0; <br />
short x = 0; <br />
<br />
i = System.Convert.ToInt16(pck.Length); <br />
while ( i > 255 ) <br />
{ <br />
i = System.Convert.ToInt16( i - 256 ); <br />
x = System.Convert.ToInt16( x + 1 ); <br />
}<br />
headerReturn = Name + char.ConvertFromUtf32(0) + char.ConvertFromUtf32(Ver) + new string(char.ConvertToUtf32(0), 2) + Strings.Chr(x) + Strings.Chr(i) + Strings.Chr(0) + Strings.Chr(int.Parse("&H" + PacketType)) + new string(Strings.Chr(0), 8) + pck; <br />
Debug.Print( headerReturn ); <br />
return headerReturn;<br />
}
|
|
|
|
|
DocH0liday wrote: with like:: headerReturn = Name(char(65));
You can replace Strings.Chr(0) with (char)0, is what I am saying.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
One section i'm having a bit of trouble with is this section::
+ new string(char.ConvertToUtf32(0), 2).. I'v tried (char(0), 2)) but i get an error..
|
|
|
|
|
you need to replace the char bit only, just like everywhere else
+ new string((char)0, 2)
I assume this constructor builds a string with n chars ( in this case, two null characters )
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi,
I know how to use indexers but can someone tell me their every day use of an indexer? At what point in development does someone say that an indexer is needed for x reason..
thanks a lot
erik
|
|
|
|
|
The obvious one is if a class acts as some sort of collection.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I would like to know how to move an e-mail item from Inbox to another folder using C# and MAPI.
TO MOVE THE ITEM I USED THE FOLLOW LINE:
message.MoveTo(oStored_ID, oStored_ID);
AND TO GET THE VARIABLES oStored_ID AND oStored_ID I USED THE FOLLOW LINES:
foreach(MAPI.InfoStore Is in (IEnumerable)session.InfoStores)
{
MapiFolderRoot = (MAPI.Folder)Is.RootFolder;
MapiFolders = (MAPI.Folders)MapiFolderRoot.Folders;
MapiFolder = (MAPI.Folder)MapiFolders.GetFirst();
while (MapiFolder != null)
{
if (MapiFolder.Name.ToString() == "Lidos")
bolMoverEmail=true;
oFolder_ID = MapiFolder.FolderID;
oStored_ID = MapiFolder.StoreID;
}
MapiFolder = (MAPI.Folder)MapiFolders.GetNext();
}
}
However when I execute the line:
message.MoveTo(oStored_ID, oStored_ID);
the item disappears from the Inbox folder but is not moving to another folder which name is "Lidos".
Thanks for your help.
Manoel Bonin
|
|
|
|
|
Hi!
Could it be that it's because of the obvious typo (oStored_ID twice)?
Even though I've never worked with MAPI I'd expect a MoveTo method to require the folderID and the storeID, what use would be oFolder_ID otherwise?
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
Thanks for your attention!
I put the corret parameter, but isn´t work.
If you know how to move an e-mail item using another method I´ll apreciate!
Just to remember: I am using Outlook 2002 and C#.
Thanks!
Manoel Bonin
|
|
|
|
|
use:
oFolder_ID = MapiFolder.ID;
is not FolderID
|
|
|
|
|
Hi everyone.
I'm currently working on an a system consisting of a service with a remote object that performs actions on a xmldatabase and on files on the harddrive, and several UI applications that communicate with this service through the remoteobject.
My problem is that the applications with their remote objects are in different scopes even though it's the "same" object so I have no way of notifying the other clients through events, that there's been a change in the database and or files.
I can't use a thread in the clients to check for changes, so I'm looking for any other way and I've failed using events.
Is there any type of global / interprocess events or messaging that I can use?
Any help is much appreciated.
-Larantz-
for those about to code, we salute you
|
|
|
|
|
If you are using 2.0 and SQL Server 2005 you can use SqlNotification.
only two letters away from being an asset
|
|
|
|
|
I forgot to say: I am using Visual Studio 2003 and Outlook 2002.
Thanks!
Manoel Bonin
|
|
|
|
|
Possibly MSMQ would be an option
only two letters away from being an asset
|
|
|
|
|
Hi.
Yes I'm using .NET 2.0, but it's not an SQL database. It's just a Windows Service which uses a xml-file for storage / database.
My problem is the communication is through remote objects and events won't reach the client applications.
Never heard of MSMQ.
I'll google it
-Larantz-
-- modified at 5:19 Friday 11th August, 2006
Ah yes Messaging Queue.
I tried that a while back with no success. Maybe I did something wrong back then.
I'll give it another try.
Thx.
for those about to code, we salute you
|
|
|
|
|
Hi everyone,
I would really appreciate some help if anyone knows the answer. I've been reading online about this topic for the past 2 days, and so far can't find an exact example to help me.
I have an unmanaged C++ dll that is comprised of several C++ classes. I need to be able to access some of the functions/procedures in this dll from my C# application. I have tried using the
[DllImport("MITT.dll")]
public static extern void Start();
method, but this results in an EntryPointNotFoundException due to the name decorating/mangling that occurs on the C++ procedure names. I then used the dumpbin.exe to find the decorated name, and used it in the DllImport EntryPoint attribute, and this worked, but I don't want to use that solution just in case the dll is recompiled at some time and the decorated name changes.
Can anyone please suggest another way to to what I'm trying to do? I've been trying to write a managed C++ wrapper class for the dll to export the functions, but so far I can't figure out how to do that, so if that is the answer, if someone could provide me an example that would be much appreciated.
Thank you in advance,
Doreen
|
|
|
|
|
moniqui wrote: I don't want to use that solution just in case the dll is recompiled at some time and the decorated name changes.
Then P/Invoke is not for you.
moniqui wrote: I've been trying to write a managed C++ wrapper class for the dll to export the functions, but so far I can't figure out how to do that,
A managed C++ (C++/CLI) wrapper works well for C++ projects, and is really the only way to call C++ class member functions. C++/CLI does not "export" the native functions. Instead, you just have some public C++/CLI method in a managed class:
ref class MyFoo
{
public void Start()
{
myNative->Start();
}
}
Something along those lines. This way, you can add a reference to your C++/CLI dll project inside your C# project, and use MyFoo as if it were written in C#:
MyFoo foo = new MyFoo();
foo.Start();
|
|
|
|
|
Hi Judah,
Thank you so much for the fast reply. A couple questions about what you posted - sorry if they are stupid ones - I'm new to the whole .net environment as well as C# and C++ :
1) What is a ref class? Is it just a normal C++ class? What type of C++ project would I add in to my solution? Would it be a DLL project or just a win32 console or what?
2) Do I need to create a .def file? If so, what directory do I put it in and how do I link it to my project for compilation?
3) Where you said "mynative->Start()", is mynative the name of my dll (so it would be MITT->Start() )? I tried that and the compiler said it couldn't resolve MITT, so I'm not sure how to make this C++ class aware of the dll.
Thanks again,
Doreen
|
|
|
|
|
moniqui wrote: What is a ref class?
In C++/CLI, it's a managed C++ class, that is, the contents of the class are exposed to other .NET languages natively, it uses .NET garbage collection, and so on. C++/CLI is new to Visual Studio 2005; if you're using Visual Studio 2003, there's managed extensions for C++, in which case you'd use the __gc keyword instead of the ref keyword. Go to the C++/CLI forum if you have more questions about C++/CLI syntax and how to wrap a native library. Basically, when write a ref class in C++/CLI, any other .NET language can immediately call into that class, no P/Invoke or interop code required; you'd use it like any other normal type.
moniqui wrote: Do I need to create a .def file?
Not from the C++/CLI project, no. For the native class you're wrapping, I'm not sure, I recommend going into the C++/CLI forum for a better answer.
moniqui wrote: Where you said "mynative->Start()", is mynative the name of my dll (so it would be MITT->Start() )? I tried that and the compiler said it couldn't resolve MITT, so I'm not sure how to make this C++ class aware of the dll.
mynative was just your C++ class instance that contained the Start method. If the Start method is not defined in a class (i.e. it's global) then you wouldn't have a mynative reference.
moniqui wrote: I'm not sure how to make this C++ class aware of the dll.
I recommend you read this article[^] on wrapping native libaries using C++/CLI.
Often times, if you just need to call one or two functions, the easiest way is through P/Invoke with [DllImport]. But if you're calling lots of functions, structures, or if the native C++ library contains its functionality inside of classes, you're best bet is with C++/CLI.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Messianic Instrumentals (with audio)
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
Hi Judah,
I wanted to thank you so much for your help. I finally got my wrapper working and can now call functions from my C# application. You're replies really got me on the right track.
Thanks again,
Doreen
|
|
|
|
|
|
You've probably already read some of these, but there are tons of articles on this subject (with examples) at The Code Project: clickety[^]
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
I have a user control that I have created as a way to plot a function. To make it flexible I defined a delegate that actually represents the function so I can use the control for different functions:
public delegate double Function(double x, double y);
In my control I add a property for the function:
<code>
private Function function;
[Browsable(false)]
public Function Function
{
get { return function; }
set
{
function = value;
}
}
So far so good, I also add a default constructor that specifies a default method to use for the function. I can create a form, add my control to it and run it and it works. The problem is if I any of the properties of the control in the designer, the designer thoughtfully adds this line to the form class:
<code>
this.functionPlot1.Function = ((Function)(resources.GetObject("functionPlot1.Function")));
And this causes a problem in the designer because the GetObject always seems to return null which results in the designer giving me the slightly comical message:
Object of type 'Function' cannot be converted to type 'Function'
Does anybody know what's going on here and how to fix it. I'm not that bothered if I can't see the function being plotting in the designer (but it would be nice if I could), but I'd like to be able to see the rest of the form, but this error stops that. Removing the offending line from the InitalizeComponents method fixes the problem temporarily, but it keeps coming back whenever I change anything.
Thanks.
|
|
|
|
|
How about defining an "example" function which is displayed when being designed?
Formula 1 - Short for "F1 Racing" - named after the standard "help" key in Windows, it's a sport where participants desperately search through software help files trying to find actual documentation. It's tedious and somewhat cruel, most matches ending in a draw as no participant is able to find anything helpful. - Shog9
Ed
|
|
|
|