Tuesday, November 11, 2008
getting to know Berkeley DB
http://simonwillison.net/2003/Nov/26/discoveringBerkeleyDB/
and this comment:
My only complaint about BerkeleyDB is that it's a wee bit flaky when not used with transactions. Databases can become corrupted, processes can deadlock, etc. I've found problems even when using CDS mode. Only problem with wrapping everything in transactions is the performance hit. So, here's what we came up with as a compromise (we use the excellent BerkeleyDB.pm module from our Perl code): lock the entire database on write with a semaphore. The overhead is negligible in terms of speed, but it's done a remarkable job of keeping our indexes very clean!
lock the entire database on write with a semaphore
???
say again?
Update (a few hours later)
i'm beginning to understand what the comment author meant....my rdbms experiece will freak out with these new ideas in berkeley db...
Friday, October 17, 2008
rpmdb: PANIC: fatal region error detected; run recovery
rpmdb: PANIC: fatal region error detected; run recovery
or actually many of these msgs
so this one helped to quickly resolve this
http://www.redhat.com/archives/fedora-list/2006-October/msg03072.html
thanks!
Wednesday, September 17, 2008
wireless configuration: Incorrect MFC DLL version installed
all started when i decided to finally uninstall vs 2003 and i guess it removed some dlls that i shouldn't have to...
i'm fairly pissed off right now so lets skip to the solution:
after deciding not reinstall windows because of this, at least i decided to put xp sp3, although i didn't really needed to...anyway this didn't help =/
after absurdly many hours of google search i came to this page - http://www.techsupportforum.com/microsoft-support/windows-xp-support/169616-incorrect-mfc-dll-version-installed-system.html
and this hint led me to open my services tab, kill the fukking 'tray service' and write this blog, quite sardonically if i may add...
damn software :)
Monday, September 15, 2008
on the market
the interviewer asked me about App domains
I was never really interested in those, said one of the benefits is the version control, gotta check this.
On multithreading...should i read more about some test cases? i spoke of some of my experience with it, its funny that when you have to talk about it its sometimes hard to elaborate on the subject...
WCF, now thats a weak point - i have experience with .Net remoting, but so many years ago I could hardly say any details, but it felt bad when the guy asked me had I had even read about WCF and I said "err...no" - gotta take care of this too, i guess
he also asked me if i had any experience with MS SQL Server, but when i started talking and mentioned the two certifications i have in this he seemed satisfied enough.
hmm...what else was there...
oh but of course - Web services - the last positions had me implementing solutions reading/writing from Web services, and this was good as when he asked me about securing web services i was stuck until i remembered how one of the service providers worked - by supplying a cookie to be used in each request after the initial login/pwd shakeup
Tuesday, August 05, 2008
Class member Entity.Id is unmapped.
so how to do this?
i created the generic method
MMethod
{
var r = from s in source.GetEntity
where s.Id == id
select s;
}
and here i started getting the errors...
first of course i could not use s.Id because the general T doesn't have Id member defined.
so i started looking where to define it - and first defined it in the interface.
now, the interface would have the property Id and some of the linq entities would also have it, but on evaluation of the var r i would get
The mapping of interface member [...] is not supported
nice...
some reading on google and i started looking for another place to add this member.
the other obvious choice - the entity class.
this seemed to be my last chance, after i tried coming up with an extension method or whatever desperate solution i could think of.
so, member added, all compiled nicely, but while in debug i decided to see what the var r evaluates to and saw a sweet message:
Class member Id is unmapped
so...WTF? Id is now nicely defined and visible everywhere, so how come this error? and what does it mean??
some browsing in google, and i come to this page
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2446465&SiteID=1
at first quick look i couldn't find any solution, but, ooo how nice that i didn't close the page immediately, because after some time i went back to it, as something stuck as a neat idea - the guy was talking about a possible bug in linq implementation, but gave a few examples of when a statement worked and when it didn't, so i decided to give a try to one of the statements that he claimed to have worked and....voila!
problem resolved.
while waiting for the build i came upon another page that confirmed this solution here: http://stuff.hornbostel.com/?cat=10
neat
thanks guys
Tuesday, July 29, 2008
xlLocalSessionChanges not working
this is the conclusion i reached when i passed XlSaveConflictResolution.xlLocalSessionChanges to workbook.SaveAs and the maddening alert showed up again.
before that i wasted a few hours wondering why my server application seemed to hang at the step when it should be writing some data to excel/csv file.
i was watching the results remotely through rdp and only later it occured to me that while i was waiting, on the server an alert appeared requiring user input - simple Yes/No/Cancel which I wasn't able to see through my remote session....
now this - setting the value to always overwrite the file and still this alertbox?
good think i quickly came upon this page:
http://www.notes411.com/dominosource/tips.nsf/0/B4EC9AD3C6CC8398802571790046F9DB!opendocument
turns out the ExcelApplication has a property that has to be set as well so this all works...cracks....excel.DisplayAlerts = false
Thanks, Mr. SCRobinson that tip had been very helpful...
Friday, July 25, 2008
The request was aborted: A connection that was expected to be kept alive was closed by the server
The operation has timed out
at System.Net.HttpWebRequest.GetRequestStream()
first i thought this might be because of firewall, proxy, something local for our network...then we turned our attention to the counterparty - they chased their logs and couldn't find anything related to timeouts or connection drops for our endpoints...
then crazy testing began - the crazy thing was that all seemed to work on the local machined and in production, then it stopped working in production, and later it stopped working in dev also...nothing miraculous here - turned our we tested wrongly in dev, so all failed everywhere.
this code is a part of a nightly process so it quickly became a pain to wait and see if the nightly process worked and if not (most of the times) run the processes manually..pain pain pain...
so before this weekend i finally sat and decided to dedicate all my time to solving this fundamental problem
i had already set KeepAlive to false and this 'seemed' to work for some time...before coming back with fierce force
so the long chase on the net began...
the first step in the correct direction was to add .Net network tracing to the app, through this app.config setting:
<system.diagnostics>
<sources>
<source name="System.Net" tracemode="includehex" maxdatasize="1024">
<listeners>
<add name="System.Net"/>
</listeners>
</source>
<source name="System.Net.Sockets">
<listeners>
<add name="System.Net"/>
</listeners>
</source>
<source name="System.Net.Cache">
<listeners>
<add name="System.Net"/>
</listeners>
</source>
</sources>
<switches>
<add name="System.Net" value="Verbose"/>
<add name="System.Net.Sockets" value="Verbose"/>
<add name="System.Net.Cache" value="Verbose"/>
</switches>
<sharedListeners>
<add name="System.Net"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="network.log"/>
</sharedListeners>
<trace autoflush="true" indentsize="4">
<listeners>
<add name="file" type="System.Diagnostics.TextWriterTraceListener" initializeData="networktrace.log"/>
</listeners>
</trace>
</system.diagnostics>
this pinpointed the problem and helped develop a reproduce-case: the time-out reoccured every third time HttpWebRequest.GetRequestStream() was called - awesome, so now what?
well the trace at least gave me hints no to what too look for in google - the timeout occured after these lines
System.Net Information: 0 : [1696] Associating HttpWebRequest#38557668 with ServicePoint#62013521
System.Net Information: 0 : [1696] Associating Connection#12798926 with HttpWebRequest#38557668
which meant, there was a problem creating the socket?
whatever - the case continued...
many people were experiencing thi serror:
The underlying connection was closed: A connection that was expected to be kept alive was closed by the server
and offered as solution setting keepalive=false, which i already had in place.
there was also a link here:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;915599
which gave another hint:
playing with ServicePointManager.MaxServicePointIdleTime property
there was also a hint to set
webRequest.ProtocolVersion=HttpVersion.Version10
which i don't to play with right now
the last and seemingly, best solution was given by Darren Neimke
http://markitup.com/Posts/Post.aspx?postId=c98db0ca-f3a8-4f49-bb96-641574274c1a:
WebRequest req = HttpWebRequest.Create("http://foo");
req.ConnectionGroupName = Guid.NewGuid().ToString();
using (Stream stream = req.GetRequestStream()) {
// do stuff here
}
a saw the ConnectionGroupName approach also here:
http://blog.josh420.com/archives/2008/02/underlying-connection-closed-fix-pesky-aspnet-webexception.aspx
still testing....will this help me not see this log below anymore?
System.Net Verbose: 0 : [3828] HttpWebRequest#48833621::Abort(The operation has timed out)
System.Net.Sockets Verbose: 0 : [3828] Socket#3798230::Dispose()
System.Net Error: 0 : [1696] Exception in the HttpWebRequest#38557668:: - The request was aborted: A connection that was expected to be kept alive was closed by the server.
System.Net Verbose: 0 : [3828] Exiting HttpWebRequest#48833621::Abort()
Friday, June 20, 2008
Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005
seeing exceptions like this make me moan in desperation... spent several hours searching the web...and although i found few good articles on this error here and here, I didn't exactly followed them because in our web app we have impersonating user, so when i opened Component Services->Computers->My Computer->DCOM Config and opened properties on Microsoft Excel Application and would give Launch permissions to this impersonated user.
It didn't work the first time, not the second, so I added this user to the local admins group.
This didn't work much either.
So in the end in some post a line containing 'Event Log' caught my attention and I swiftly opened the event viewer where, under System, found several relevant error messages, one of which
The application-specific permission settings do not grant Local Activation permission for the COM Server application with CLSID...
gave me the info I needed - turns out I really had to put the ASPNET user account under which asp.net is running.
This solved the problem
I still have doubts as to why the ASPNET account should be held responsible and not the impersonated one, but....whatever!
Thursday, June 19, 2008
MS SQL Server Management Studio - Create new table/Add new column
It was like whenever I put value different than 50, Management Studio would revert the value back to 50, and I'd have to change the value again and this time it would work.
Now today I noticed something - this would happen everytime I put a value of varchar(10), but not for other values!
So for varchar(10) it is reverted to varchar(50),
but for varchar(20) the value is preserved when I change the focus....funny, no?
Tuesday, June 17, 2008
Assembly.GetEntryAssembly()
I have to use it in Asp.net though, so at one point I got to a method using unguarded Assembly.GetEntryAssembly() call that failed.
After a little research and found this in the MSDN:
The GetEntryAssembly method can return null reference (Nothing in Visual Basic) when a managed assembly has been loaded from an unmanaged application
and became evident that the reason for the problem was that the library was call from the unmanaged IIS process.
I searched for a generic solution, but finally only managed to find a hint here:http://www.developersdex.com/asp/message.asp?p=2912&r=5817390
so now I'll add this code to solve the problem
if (null != Assembly.GetEntryAssembly())
{
// proceed with Assembly.GetEntryAssembly()
}
Else
{
// read a setting from the config file and set the entry assembly to this value if not empty
System.Configuration.ConfigurationManager.AppSettings["EntryAssembly"]
}
and thats all for now ...
Monday, May 19, 2008
Linq OrderBy Descending fun
The underlying c# is scary of course, reminding me of the nightmare from the C++ generics/COM days. But at least now the IDE has evolved and IntelliSense works nicely.
Anyway - I came to the point were some tweaking was needed and some parametrizing - mainly i needed the order by to be runtime desided - 'dynamic' if you wish - so i started reading around blogs and sample code, but all seem to be aiming too high and I didn't have much time to really dive into Linq (which I should do someday anyway)... still quantity changes lead to some understanding of the problem in question , mostly after looking at (not really reading) samples at http://www.ddj.com/database/205604421, http://srtsolutions.com/blogs/billwagner/archive/2006/03/29/ordering-linq-results.aspx
and http://community.bartdesmet.net/blogs/bart/archive/2008/04/27/q-is-iqueryable-the-right-choice-for-me.aspx
I came up with this really small snippet of code that solved easily my problem
public static OrderedEnumerableRowCollection
OrderByEnhanced
(this EnumerableRowCollection
{
if (ASC)
return source.OrderBy(keySelector);
else
return source.OrderByDescending(keySelector);
}
ain't it funny - it is so simple, but looking for a solution to my problem lead me to reading a lot about Linq and helped me learn a lot too, so that time was not waisted, so to say
cha!
Wednesday, April 16, 2008
OUTPUT clause in INSERT/UPDATE/DELETE statements
I had some hopes for it but turns out i cant write something like
insert targettable (col1,col2)
output Inserted.col1, sourcetable.somecol
select somecol1,somecol2 from sourcetable
that is - i cant output values from the Inserted and also values from the source table :(
a bit disappointing in a way, of course, because i wanted to have backwards mapping between the source and inserted tables, but now I just decided to use one of the columns in the inserted table as this mapping ids placeholder
voila...
EDIT:
according to msdn article on T-SQL Delete
it is possible to OUTPUT exactly what I need...
DELETE Production.ProductProductPhoto
OUTPUT DELETED.ProductID,
p.Name,
p.ProductModelID,
DELETED.ProductPhotoID
INTO @MyTableVar
FROM Production.ProductProductPhoto AS ph
JOIN Production.Product as p
ON ph.ProductID = p.ProductID
WHERE p.ProductModelID BETWEEN 120 and 130;
strange...now I'll have to achieve the same results somehow...
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
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
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....
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 :)