Reputation: 645
I'll just cut to the chase and give you some background information: Our application has quite massive startup issues, taking up to 20(!!) seconds for our webservice to respond to the first request. Everything runs quite fast after this initial lag, but the initial lag itself is quite a big problem.
At any rate, I've been doing research on the issue for the past two days or so, I have managed to get a proper log of requests sent back and forth and it turned out that the issue lies in creating XMLSerializer, which quite simply takes ages.
Now after even more googling, I have discovered the 'Generate serialization assembly' property and that it doesn't quite work properly. To force the serialization, I have followed this solution over here: https://stackoverflow.com/a/8798289/2401855
Now that has actually worked, except... Well, it didn't. When I try to compile the webservice, Sgen throws the 'There was an error reflecting type' error and I can't quite proceed. And finally, here come my questions:
How do I get the actual error Sgen.exe has thrown? It might just help me understand what's going on better, but I was trying to look into system log files that codeproject was referring to and didn't quite find anything.
Why does the error get thrown in the first place? It gets thrown for this particular bit of code:
public class Enums
{
public enum TypNakladu
{
Prijmy = 1,
Vydaje = 2
}
public static string GetEnumDescription(Enum value)
{
FieldInfo fi = value.GetType().GetField(value.ToString());
DescriptionAttribute[] attributes =
(DescriptionAttribute[])fi.GetCustomAttributes(
typeof(DescriptionAttribute),
false);
if (attributes != null &&
attributes.Length > 0)
return attributes[0].Description;
else
return value.ToString();
}
}
'TypNakladu' is the enum that sgen doesn't seem to like. Is there any way to make sgen to just ignore this particular class, or enums contained within? (there are more, but when I comment one out, sgen just complains about the next one)
And that's just about it I suppose. I'm sorry if I'm making some incredibly dumb mistake here, I'm not very experienced when it comes to ASP.NET webservices.
Upvotes: 1
Views: 575
Reputation: 645
Very well, now I actually have some answers, so here we go:
As for error thrown by Sgen.exe, the best way to get was to quite simply not run it via Visual Studio IDE and just navigate to the folder with my server. I didn't do it in the first place because running Sgen.exe directly gave me even more errors - turns out I've had two versions of Sgen installed on my harddrive. They came natively with two installations of Visual Studio.
Now for the error itself, problem was that there were two instances of the same enum name, as simple as that.
Upvotes: 1