|
I'm having problems sending an object to a web service. Instead of passing it directly to a web method, the proxy generates an alternative class that I must use.
To avoid that, can I xml serialize the object and send it directly to the web service?
If it's possible, can you briefly explain how to do that or where can I get the info?
Regards,
Diego F.
|
|
|
|
|
What do you want exactly do? You can edit your messages to web service , see the documrntation for SoapExtension class in MSDN and googling for examples.
Mazy
"One who dives deep gets the pearls,the burning desire for realization brings the goal nearer." - Babuji
|
|
|
|
|
What I want is working in the client with my custom class instead of working with the class that the proxy generates. Then, I want to pass directly the custom objects to the web service.
To get that, I must first use a fully XML serializable class, so I must have a wrapping class that uses my custom object as a public attribute.
The question is how to implement the wrapper as simple as possible. I saw an example but with too clases: the main class, an implementation of CollectionBase for the main class, a third class that uses the collection as a parameter, and the fourth that gives functionality to the third class.
|
|
|
|
|
I have a project that contains several classes.
Class1 has a public variable, let's say var2, of type Class2.
Class2 has a public variable, x, of type ArrayList.
Finally, in x I load objects of another class, Class3, which has a public property named Myprop.
I cannot access MyProp from Class1.
(like this: var2.x[index].Myprop). Why? What am I doing wrong?
I think I have to announce somehow that in x I load Class3 objects (my x is declared like this: public ArrayList x=new ArrayList())... I don't know.
Please help me!
Thanks
Cristina
|
|
|
|
|
You have to cast the object returned from your Class2 accessor:
((Class3)var2.x[index]).Myprop
To be safe, however, you can't be sure that x at the specified index will have an object instance:
Class3 c = (Class3)var2.x[index];
if (c != null)
{
}
else
{
}
Alternately, you can use the as keyword:
Class3 c = var2.x[index] as Class3;
Ian Mariano - Bliki | Blog
"We are all wave equations in the information matrix of the universe" - me
|
|
|
|
|
ian mariano wrote:
Alternately, you can use the as keyword
As I know, it's not an alternative, the following line would throw an exception if var2.x[index] is not of type Class3 :
Class3 c = (Class3)var2.x[index];
but this will not:
Class3 c = var2.x[index] as Class3;
Don't forget, that's Persian Gulf not Arabian gulf!
Murphy: Click Here![^] I'm thirsty like sun, more landless than wind...
|
|
|
|
|
The latter is still an alternative which is safer than a straight cast, since it won't throw an exception, it will evaluate to null if it can't be cast.
Either usage depends on the intent. I use the former method when ensured of a type (but I still do checks like using Type.IsAssignableFrom ) .. as is just shorter
Ian Mariano - Bliki | Blog
"We are all wave equations in the information matrix of the universe" - me
|
|
|
|
|
Things are stored in ArrayList class in Object variables. So you need to cast them to your desired class when required:
((Class3)var2.x[index]).Myprop
I hope this helps!
abcdabcdabcdabcda
Don't forget, that's Persian Gulf not Arabian gulf!
Murphy: Click Here![^] I'm thirsty like sun, more landless than wind...
|
|
|
|
|
Cristina,
Is there a good reason to use public variables/fields? Are these private internal classes of another class?
-Jeff
here, bloggy bloggy
|
|
|
|
|
|
Clear the list, or the checks?
chkList.Items.Clear();
The following removes all the checks:
foreach (int index in chkList.CheckedIndicies)
chkList.SetItemChecked(index, false);
Ian Mariano - Bliki | Blog
"We are all wave equations in the information matrix of the universe" - me
|
|
|
|
|
How to close an Task Manager window which is already open. Is there a way to get the process id of the Task Manager and end it?
Anykind of help is highly appreciated.
CHEERS
I.T. D.U.D.E
|
|
|
|
|
Hit escape
Use FindWindow to locate the window and send it a WM_KEYDOWN with VK_ESC .
Ian Mariano - Bliki | Blog
"We are all wave equations in the information matrix of the universe" - me
|
|
|
|
|
Or just use something like this, which is all managed code:
Process[] procs = Process.GetProcessesByName("taskmgr");
if (procs != null)
foreach (Process proc in procs)
proc.Kill();
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I try to avoid Kill ing processes unless it's a last resort.
To quote MSDN: "Data edited by the process or resources allocated to the process can be lost if you call Kill. Kill causes an abnormal process termination and should be used only when necessary."
The task manager opens handles to the performance counters amongst other things. Just Kill ing it may not release them cleanly. Latter versions of Windows are better at handling reclaiming such resources, but I feel it's better to play nice.
Ian Mariano - Bliki | Blog
"We are all wave equations in the information matrix of the universe" - me
|
|
|
|
|
There's always Process.CloseMainWindow . The idea is to avoid P/Invoking when possible since it can help lead to more portable code. It was an example and I would hope that for most code samples I post they just don't take them as-is - the ol' copy and paste. I try to teach people, not hand them the answers so they can continue their pursuit in ignorance. You may a good point, though.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Yes, and I believe that TaskMan.exe is a well-formed Windows app.
Process.CloseMainWindow (MSDN) "in a well-formed application, closes child windows and revokes all running message loops for the application. The request to exit the process by calling CloseMainWindow does not force the application to quit...The behavior of CloseMainWindow is identical to that of a user closing an application's main window using the system menu. Therefore, the request to exit the process by closing the main window does not force the application to quit immediately."
Ian Mariano - Bliki | Blog
"We are all wave equations in the information matrix of the universe" - me
|
|
|
|
|
Can somebody tell me how to Unregister a Service Process so that its name is not displayed in the TaskManager Process List. I required the solution for Windows XP platform. For Win9x platform, we can do it with RegisterServiceProcess API supported by Kernel32.dll. But the same thing is not working with WindowsXP since kernel32.dll doesnot support this API or It does not have this entry point.
Is there some other way to implement this.
CHEERS
I.T. D.U.D.E
|
|
|
|
|
|
Hi
Im developing a program that needs to send emails through outlook because of varius reasons.
This is no problem at first glance using this example: http://support.microsoft.com/default.aspx?id=310263 .. like it says on the page its only for
outlook 2002 and 2003 cause of the mailitem object.
my question then .. how can i make the code work with all outlookz?
regards MTP
|
|
|
|
|
First of all, do you need to actually submit it, or just create a new mail message? If it's the latter case, then just use something like this:
Proces.Start("mailto:user@domain.com?Subject=test"); This will create a new message with any initial subject or body message you specify using the default MAPI client.
If you want a tried-and-true way, just communicate with the SMTP server yourself (the .NET Framework 2.0 will have much better support for this, including support for multi-part MIME messages). There is code on the 'net to get the MX record for a mail host (I've got a solution floating around somewhere here on CodeProject) and use the simple SMTP commands and a TcpClient to send mail to the SMTP server. There are plenty examples of this on the 'net as well. Just google.
You'll have a hard time finding a solution that works with all Outlook versions because they have changed a lot from version to version, patching security holes with terrible solutions. The best way - though pretty inflexible - is through MAPI. There are articles here on CodeProject that cover this. Not everything is available using MAPI, but enough to create and send an email (not browse the address book, however, which is only available to C/C++ clients - or a .NET assembly that P/Invokes the functionality required).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi ..
thanks for the anwser but.
yeah ive tryed Proces.Start thing but i really need my program to fix up the mail for the user with an attatchment which cant be done with the mailto command :'( or atleas i cant make my outlook accept the input i am sending it (mailto:bla@bla.dk?attachment=file:///c:/bla.bla (and alot of other syntaxes)).
Ive already made my own emailsender with mailmessage but then the user wont see the sent / deletet items in outlook which id like em to do.
Is there a way to just open outlook and put an email into one of the folders .. like the sent items? or getting the mailto command to accept attachments?
regards
MTP
|
|
|
|
|
If you're going to try to just put an email into a folder, you might as well use Outlook to send as well.
My suggestion is to just make that a system requirement: Outlook 2002 or above. Or, as I said, search this site for more information on MAPI. You can google, too.
The thing is that MAPI is pretty basic functionality and Microsoft has limited what MAPI can do (like enumerate the address book). They created Extended MAPI (EMAPI) to replace that functionality, but EMAPI does not expose any automation interfaces so that only early-binding languages can use it (C/C++ mainly) - so that script can't access it (and a COM interop library can't be created from it). You can encapsulate EMAPI using .NET, however, by P/Invoking the require methods and creating the IUnknown interfaces yourself. Several people have already done this, so you can use their implementation.
You could also check out Simple MAPI.NET[^] here on CodeProject. This implementation uses MAPI so there will be a security warning for Outlook XP and 2003 that tells the user a program is trying to access certain features, which they can allow or deny.
Encapsulating EMAPI is your best bet, and should work just fine for Outlook 2000 and newer. Anything older would probably be rare, running on a machine that can't run the .NET Framework anyway (i.e., Windows 95), or become too big of a burden and too costly to develop.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi
Thanks very much for the info.
I'll try to give emapi a shot then.
I have tryed the simple mapi example here on the site and it works like a charm. But the problems keeps coming .. the simple mapi example dosnt support the option to add headers to the email like "Disposition-Notification-To". but ill have to settel then.
But once again thanks for the help
MTP
|
|
|
|
|
Hi!
Is it possible to get the name of a variable as a string?
For the following example I want to get the string "variable".
<br />
class Test<br />
{<br />
private int variable;<br />
}<br />
I looked into Reflection namespace, but found nothing that fits well. The namespace provides class FieldInfo but unfortunately the only way to get an instance are the methods GetField or the GetFields . Both methods would more or less require that i already know the name of the variable.
THX in advance!
|
|
|
|