Friday, April 11, 2008

Server: Msg 7347, Level 16, State 1, Line 1 OLE DB provider 'SQLOLEDB' returned an unexpected data length for the fixed-length column

I got the error described here http://support.microsoft.com/kb/920930
when running a test select * from a view on a linked server





Server: Msg 7347, Level 16, State 1, Line 1 OLE DB provider 'SQLOLEDB' returned an unexpected data length for the fixed-length column '[LinkedServerName].[DBName].[OwnerName].[TableOrViewName].ColumnName'. The expected data length is n, while the returned data length is m.





when searching on google web/groups the compains were for sql server 2000 and below so not much help until i decided run the same query on the linked server itself and it went through without a problem.
turned out the column in question (the one that reportedly returned larger data than expected) is empty.
so i just rewrote the query to return only a subset of data i needed and all worked nicely

so...fun...

Tuesday, March 25, 2008

/LM/W3SVC/1/ROOT/AppName is unavailable

So I created this neat c# web service and went to deploy it to our clustered environment.
Before that I ran the web setup on a dev server and it installed flawlessly so what a big surprise it was that when i tried to install it in production I got this lovely message:



(it says: 'the specified path 'lm/w3svc/1/root/yourappname' is unavailable. the internet information server might not be running or the path exists and is redirected to another machine. please check the status of this virtual directory in the internet services manager')

don't you love it when all is fine while you develop but when you try to deploy something maddeningly breaks...

Few hours of google search didn't bring any solutions, so i had to figure it out myself, being the genius IIS admin, that i am (not).
first i thought this might be due to our production servers being in a cluster, (mis?)lead by the '...is redirected to another machine' part of the message, but even taking one or the other of the servers off the cluster (temporarily) didn't help.
after a few similar guess/error tries i simply created a folder in inetpub where my web service would be dwelling, created a virtual folder pointing to this empty folder, run the setup again and.....it didnt break this time(!) - simply copied the contents of the web service and off we went

so i guess Okam's razor works...even for deploying c# web service solutions in IIS

lovely ;-)

Tuesday, February 19, 2008

.net, soap, web services and enums....

imagine you have a class like this one


public class BaseClass
{
public BaseClass() {}

protected TheEnum enumcho=TheEnum.First;
public TheEnum Enumcho
{
get { return enumcho; }
}
}


where TheEnum is some enumeration.

now, if you want to use and export this class in a webservice, you would decorate it with [Serializible] and expect everything to work just fine...
so thought i until i discovered that the class generated for the proxy would look like


[System.....]
public partial class BaseClass
{
}


yes, you saw that correctly - its just an empty class, and something like this is enough to drive one crazy...
took me long 2-3 hours to find a solution, and it was hard because as always - the oracle (google) is only giving helpful answers when you're asking the correct questions

.net serialize enum?
c# enum soap?
enum how serialize soap c#?
enum not serialized web service c#?

and a big load of similar ones, to not much help until on one of the searches i came upon this one, where bruce johnson wrote about his problems playing with java/.net web services and especially this one where 'Wim' had problems serializing enum fields. and that probably wouldn't be of much help either had he not mentioned this weird thing: "all fields are serialized, except the enum field...strange thing is, when i rename the member field, it does get serialized" - this was enough to get me started to look for the crazy explanation for the problem (remember?-when all the logic conclusions lead to nothing its time to look for the illogical answers...)

and i finally found it when i added a setter method to the property, like this...


public TheEnum Enumcho
{
get { return enumcho; }
set { int i=0; }
}



to my relief this solved the problem and the property was finally added to the definition of the class in the proxy....breathe...and relax....3 hours waisted...

hope this will be helpful to somebody else too :)