|
Damn, must be my machine.
|
|
|
|
|
|
Thank you verry mutch for your answer, so i need to merge the word file in the memory, because i don't want to generate all 1000 files. please help me.
|
|
|
|
|
Hi,
I have a problem in deserializing the xml which is coming from Java side in soap form.
Here is my code..
var responseText = res.XmlDocument.GetElementsByTagName("soap:Body").Item(0).InnerXml;
var memoryStream = new MemoryStream(Encoding.Default.GetBytes(responseText));
var ClsEmpResponse = (Request.ClsEmp.EmpResponse)xmlSerializer.Deserialize(memoryStream);
_oLog.LogStackTrace("*************DAE VIEW REQUEST*************");
_oLog.LogStackTrace(responseText.ToString());
return ClsEmpResponse;
here in this code, am getting the response as it is saved in database(for ex, it contain Nested Condition:3) in responseText.
but after i pass it to the memory stream, it is showing that it contain only 1 condition in the loop in ClsEmpResponse.
ClsEmp is the class contain in Request folder in my application, which is having some fields, where i read and write the data into/from that field.
so can u tell me what is d problem here..
Why it is not taking the exact value which is coming in responseText.
why its not reading the same xml format which is in
|
|
|
|
|
I suspect that it is because you haven't told it what the soap: prefix means.
Here's what I had to do to use the xi: prefix:
System.Xml.XmlNamespaceManager nsm =
new System.Xml.XmlNamespaceManager ( Document.NameTable ) ;
nsm.AddNamespace ( "xi" , "http://www.w3.org/2001/XInclude" ) ;
System.Xml.XmlNode nod ;
while ( ( nod = Document.SelectSingleNode ( "//xi:include" , nsm ) ) != null )
Try something like that.
|
|
|
|
|
Hi,
I would like to know how to make multiple asynchronous web service method calls in the same thread? What if the web service method cannot be checked by IAsyncResult status operation statement but just invoking the MethodNameAsync(X,Y,Z).
What I think is sleeping the thread shouldn't be the way to handle it because lets assume that 20 of form controls inside the form uses web methods to populate themselves and one of the control's value is used as an argument to call another asynchronous method to populate another control in the form .
The problem is I have a few asynchronous call in the same thread and I couldn't figure it out how to create waits between the each asynchronous calls until it gets loaded completely. Is there a way to load all asynchronous methods before the form loads.
if you enlighten me about the solution, I would really appreciate it. This is my first Web Service client issue to solve and I have no experience about it.
Thanks.
What a curious mind needs to discover knowledge is noting else than a pin-hole.
modified on Tuesday, May 24, 2011 9:28 AM
|
|
|
|
|
JUNEYT wrote: Is there a way to load all asynchronous methods before the form loads.
If the calls are truly asynchronous then there should be some notification of completion (like an event).
I use something similar to the DomainContextLoadBatch class found in this article[^]. This class lets you queue up a bunch of asynchronous calls and doesn't notify you until they have all completed. The class as shown is for WCF RIA Services LoadOperation calls, but could easily be modified for other webservice call types.
*edit* If you use that class as a guide, please note that as shown the class is NOT thread safe, so if your webservice calls can complete on other threads you'll need to make sure at least the class' single completion handler is thread safe.
You shouldn't have to sleep and wait...that negates the whole purpose of asynchronous calls...
Mark Salsbery
Microsoft MVP - Visual C++
modified on Tuesday, May 24, 2011 12:03 PM
|
|
|
|
|
List<MyStyle> styles = new List<MyStyle>();
foreach (var item in items)
{
styles.Add(GetMyStyle(item.style));
}
- Regards - J O N
A good thing is a bad thing if it keeps you from the best thing. - Dr. Adrian Rogers
|
|
|
|
|
I don't think LINQ is meant to do this.
LINQ is "Language Integrated Query", a query being something of a question used to select, modify or delete data.
The performance gain, if any, will be slight.
I actually think it might slow it down.
But if you must...
(Doing this from memory)
List<MyStyle> styles = new List<MyStyle>();
styles.AddRange((MyStyle[])(from item in items select GetMyStyle(item.style)).ToArray());
|
|
|
|
|
may be you are right. i was just wondering how to do that using LINQ.
anyway thanks for the reply.
- Regards - J O N
A good thing is a bad thing if it keeps you from the best thing. - Dr. Adrian Rogers
|
|
|
|
|
Off the top of my head:
List<MyStyle> styles = items.Select(item => GetMyStyle(item.style)).ToList();
|
|
|
|
|
|
It's LINQ using a Lambda expression, as a lot of LINQ does.
|
|
|
|
|
thanks..
- Regards - J O N
A good thing is a bad thing if it keeps you from the best thing. - Dr. Adrian Rogers
|
|
|
|
|
No problem. Glad to help.
|
|
|
|
|
I think you may use its constructor to add values in it.
List<MyStyle> l = new List<MyStyle>(items.Select(s => GetMyStyle(s.style)));
Thanks
|
|
|
|
|
try like this ,
var styles=items.Select(item=>GetMyStyle(item.Style)).ToList();
sorry...answers are already there
modified on Wednesday, May 25, 2011 9:29 AM
|
|
|
|
|
Hi all,
I need some advice here, I hope somebody can help me.
I have the following class structure (simplified):
public class Bar: IDisposable {...}
public abstract class FooBase: IDisposable
{
Bar bar;
bool disposed;
internal FooBase(Bar bar)
{
this.bar=bar;
}
public void Dispose()
{
if (!this.disposed)
{
this.bar.Dispose(true);
GC.SupressFinalize(this);
this.disposed = true;
}
}
protected void Dipose(bool disposing)
{
if (disposing)
{
this.bar.Dispose();
}
}
}
public FooA: Foo {...}
public FooB: Foo {...}
public static class FooProvider
{
public static FooA GetFooA()
{
Bar bar = new Bar();
...
return new FooA(bar);
}
public static FooB GetFooB()
{
Bar bar = new Bar();
...
return new FooB(bar);
}
...
}
When I run Code Analysis on this, I get Warnings CA2000 on all 'CreateFooX()' methods of the FooProvider class. This warning gives the following message: "Microsoft. Reliability: In method 'FooProvider.GetFooX()', call System.IDisposable.Dispose on object 'bar' before all references to it are out of scope."
Microsoft recommends to never supress this warning but I'm not really sure its warning about a real problem in the code. True that 'bar' is not disposed before going out of scope in whatever 'CreateFooX()' method we consider but a reference to it lives on in the 'FooX' object which eventually will get disposed and will in turn take care of disposing 'bar'.
Am I understanding something wrong about how the Dispose pattern should work and I have some fundamental flaw in my code or should I just supress this warning?
Thanks for any advice.
|
|
|
|
|
you can fix this warning by applying 'using'.Do like this.
public static FooA GetFooA()
{
using(var bar = new Bar())
{
...
return new FooA(bar);
}
}
public static FooB GetFooB()
{
using(var bar = new Bar())
{
...
return new FooB(bar);
}
}
|
|
|
|
|
OK. Now have a think about what effect calling Dispose on an item that you've just allocated via a constructor will be. Explain to the OP what happens when you attempt to access bar in FooB or FooA.
|
|
|
|
|
Thanks for the reply but that is not a valid solution.
If I do that, GetFooX() will be returning an invalid FooX object(disposed bar).
|
|
|
|
|
No , Just check the scope of "using". It will track the instance 'bar'
|
|
|
|
|
This is why I said you should explain the effect of the using statement further, I knew it would cause you confusion.
|
|
|
|
|
I'm sorry but that is wrong.
A use statement is just syntactic sugar for a try finally block. What you are proposing translates to:
Bar bar = null;
try
{
bar = new Bar();
...
return new FooX(bar);
}
finally
{
if (bar != null)
{
bar.Dispose();
}
}
When the method gets to the return statement, it will execute the finally clause before exiting the method's scope returning a FooX object with a disposed bar.
If you are not convinced execute the following code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Tests
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Creating FooA 'fooA' from GetFooAWithUsingStatement.");
FooA fooA=FooProvider.GetFooAWithUsingStatement();
Console.WriteLine("'fooA' internal bar is disposed: {0}", fooA.InternalBarIsDisposed);
Console.WriteLine("Disposing 'fooA'");
fooA.Dispose();
Console.WriteLine("'fooA' internal bar is disposed: {0}", fooA.InternalBarIsDisposed);
Console.WriteLine();
Console.WriteLine("Creating FooA 'fooA' from GetFooAWithoutUsingStatement.");
fooA = FooProvider.GetFooWithoutUsingStatement();
Console.WriteLine("'fooA' internal bar is disposed: {0}", fooA.InternalBarIsDisposed);
Console.WriteLine("Disposing 'fooA'");
fooA.Dispose();
Console.WriteLine("'fooA' internal bar is disposed: {0}", fooA.InternalBarIsDisposed);
Console.Write("Press a key to exit.");
Console.ReadKey();
}
}
class Bar : IDisposable
{
bool disposed;
public void Dispose()
{
this.disposed = true;
}
public bool IsDisposed { get { return this.disposed; } }
}
static class FooProvider
{
public static FooA GetFooAWithUsingStatement()
{
using (Bar bar = new Bar())
{
return new FooA(bar);
}
}
public static FooA GetFooWithoutUsingStatement()
{
Bar bar = new Bar();
return new FooA(bar);
}
}
class FooBase : IDisposable
{
bool disposed;
Bar bar;
internal FooBase(Bar bar)
{
this.bar = bar;
}
public void Dispose()
{
Dispose(true);
this.disposed = true;
}
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
this.bar.Dispose();
}
}
public bool IsDisposed { get { return this.disposed; } }
public bool InternalBarIsDisposed { get { return this.bar.IsDisposed; } }
}
class FooA : FooBase
{
public FooA(Bar bar)
: base(bar)
{
}
}
}
To make things clear I should clarify that 'FooX' needs 'bar' to not be disposed during its lifetime. I thought I had made myself clear indirectly by needing to dispose 'bar' in 'FooBase.Dispose()' method.
My question remains the same: Is the Warning I'm getting valid or is the Analyzer not understanding the way the code really works and I can supress it even if MS guidelines says you should not do so?
Edit: typos (not all by any means)
modified on Tuesday, May 24, 2011 9:37 AM
|
|
|
|
|
Then it is better to suppress the warning.
|
|
|
|