Monday, December 31, 2007

objectdisposedexception - Safe handle has been closed Pt 3

I don't know if this will help in the error, but I did come across a reference to add to the app.config of your app to set the following flag. This may mask other errors, and I haven't tested it out yet. But it is one more option to add:

legacyunhandledexceptionpolicy enabled="1"

Under the config section of the app.config.

objectdisposedexception - Safe handle has been closed Pt. 2

In doing some more research, I found this bit from a Microsoft Feedback page:


The issue reported to us occurs not because the iDB2NamedEvent class calls the Handle property, but because it calls it while the WaitHandle is registered with the ThreadPool through ThreadPool.RegisterWaitForSingleObject. This is not a valid operation.

The workaround is either to avoid closing the handle manually in the finalizer for the iDB2NamedEvent class (the runtime will take care of that anyway), or unregister the WaitHandle from the ThreadPool before closing the handle. Option 1 is probably preferable.


It sounds like this is the only case that you should not call the disposed method. Instead, let program clean it up on it's own. Yuck.

Friday, December 28, 2007

objectdisposedexception - Safe handle has been closed

It's been a while since I've posted, and here is my current issue. I'm writting a call from an asp.net webservice to an IBM as/400 storedproc via IBM's "IBM DB2 UDB for iSeries .NET Provider"

It works great! I have a stored procedure on the iSeries system that calls an internal program. I can make the call. However, when my project stops or closes down, I get an ObjectDisposedException, "Safe handle has been closed" I've seen a few posts here and there about it, and finally stumbled across this bit from IBM:

SE22506 - CA400EXP-IDB2DATA .NET PROVIDER WITH .NET FRAMEWORK 2.0
At least they have a patch. Though, I don't know how long it will take our team to get the patch installed, tested and move to production. Well, hopefully it won't take long.

But in any case, at least now I have a path to go down. And according to their records it will work on V5R2M0, V5R3M0, and V5R4M0. We'll see I guess.

If anyone has some other method for working around this error, I'd love to hear about it.

Friday, October 12, 2007

DataFormatString Time and Date

So you have abound control, and want to only display the time portion? Or just the Date? Well, to start, that bound control must have HtmlEncode="false". Now, the only warning that I've seen on it, is that it maybe subject to an injection attack. And if you're worried about that, then you should probably use a templateitem instead.

Once you have the HtmlEncode="false" assigned to the bound item, use the DataFormatString="{0:t}" to get just the short time, and DataFormatString="{0:d}" to get a short date. You should be able to use any number of the formats in here to format it anyway you like. It took me some time to find these seemingly steps to get just the time on a datagrid column.

Mike

Friday, July 6, 2007

VMWare, Vista and VPNs part 2 (over wireless)

Note: This is over a wireless connection, over a wired connection, things work just fine.

I did it! I finally got settings worked out to be able to VPN into work from home with my Virtual Machine (running XP) on my Vista system.

First, I had to set the Virtual Machine to use NAT connections, not Bridged.

Second, I had to go into the Network Connections, and make sure that the VMWare Network Adapters to a Private Network, NOT Public.

Third, I had to connect to the VPN via Vista, NOT inside of the VM (as I previously had to do when I was hard wired in)

Fourth, I had to use Microsoft's Firewall Client for ISA server in Vista (the host machine) in order to get Internet access (though, this step will depend on your network).

Fifth, I also had to set the proxy server directly in IE inside the VM so that I can get internet access via the VM.

Enjoy!

Mike

Tuesday, June 12, 2007

VMWare, Vista and VPNs are vividly vulgar

Well, I just upgraded to a new work laptop. It came with vista business and so far I'm duly impressed with Vista. All development at work is done inside virtual machines, using VMWare workstation 6. So far so good. I connected vista to our domain, loaded workstation 6, and connected my external drive.

No probs so far. I load up my VMs, and I'm back in business! I spend the rest of the day working, and head home.

And home is where the troubles began. I have a wireless network at home. No prob. I get vista connected, and can surf like normal. However, when I go to start up my VMs to check on work stuff, I can't connect to the VPN inside the VM (which is Windows XP). Hmmm. So I connect to the VPN through Vista. No problem. So I startup the VM again, and try to connect to the network. No can do. It will get an IP from my dhcp server, but not make it anywhere over the VPN.

So I turn on the Microsoft Firewall client in Vista. Still can't get anywhere in the Virtual Machine.

I eventually was able to have the VPN connected in Vista, and the vpn connecting in the Virtual machine, but it wouldn't authenticate that "nested" vpn connection.

Trying just about every combination, I finally gave up and went upstairs. It was there I happened to notice my lone network port in the wall of my bedroom. Hmmmm. It couldn't be that simple. I grabbed a network cable, plugged it in the laptop, and now I'm connected to the VPN, inside the Virtual Machine, working once again.

Bummer that I can't use wireless for it, but someone else may have the answer to that.

Mike

Monday, June 4, 2007

Could not find resource assembly

I'm currently working on PDA app for our inventory program. I'm tweaking the program to point to a different webservice.

After deploying the app to the PDA, it started the connection to the webservice, when the following error popped up:

Could not find resource assembly

Hmmm. . . After some researching I found an msdn blog that mentioned that this error isn't an error that occurs in the apps resource assembly, but because the PDA does't have the resource assembly that contains the error codes that are used for display.

The blog contained a link to msdn to read through the issue, but alas, that pointed to a File Not Found error on the msdn. Oh well.

After searching, you need to copy the System_SR_enu.cab file to your PDA and install it.

Once I did that, the correct error message appeared and I moved on to debugging it. yeah!

Wednesday, May 30, 2007

Microsoft "Surface"

http://today.msnbc.msn.com/id/18928656
MSNBC is reporting today the latest and sounds like last major project for Bill Gates. Think of a touch screen that is super-sized combined with a watcom tablet. At least that's what I think of it. It looks pretty cool!

Hmmm, of course, as a coffee table you'd have to be careful when you put your feet up, or put a cup of hot coffee on it... then again, maybe it'll tell you the temperature of the coffee or when it is low (by weight maybe) and trigger the pot to start brewing some more hot coffee... oh the possibilities.

Thursday, May 24, 2007

Open Source Softdrinks

Now food is getting into the open source arena:

How to make Open Cola

Yes, now you too can expand and improve upon the Open Source Cola. Hmmm.... I just hope I don't find any bugs in it.

Tuesday, May 22, 2007

Don't forget about User encryption with SSIS

So when you finally get your package done, and you want to run it scheduled, be sure to read over this http://support.microsoft.com/kb/918760 to make sure everything is hooked up. I hit this issue a couple weeks ago and forgot about it again today. At least now it's in my blog, so I can find it without having to google it.

Here is another good link regarding importing a package and getting the permissions right: http://www.cubido.at/Blog/tabid/176/EntryID/71/Default.aspx

More SSIS woes...

When using a Datareader with ADO.NET, a 5 character string coming from our AS/400 returns to me trimmed (everything I get from the 400 is fixed length). Where as when i pull the data from our sql servers, it's not coming back trimmed. It must be something to do with IBM's ADO.NET connection

SSIS: Flat File Connection Manager gotchyas

So my latest issue with SSIS: The Flat File Connection Manager.

Everything works fine, unless you want to add or remove a column from the source that the manager is connected to. Normally, with the other managers, etc. They pick up the change, or let you "fix" the change. Not with the Flat File Connection manager.

From what I've been able to find, you have to delete the manager, recreate it, and re-assign it to your flat file destination in order to "pick up" that extra column that you wanted. I use the flat file only for debugging the output of my package, before actually updating the database itself. Handy, except for that pesky issue. If I click the reset columns, I would expect to have the columns reset to the input. Nope, everything goes blank and you have to either delete the manager or hand enter the columns. Yikes!

Oh yeah, one more gotcha: if you run it without column headings check for the first row, then decide that you really want them, be sure to delete the files first, or you'll get really hosed.

Pretty much you'll be forced to delete the manager and recreate it.

Wednesday, May 16, 2007

SSIS packages and Variables

Today, I spent most of the day trying to figure out why the following:
(this is inside of an SSIS package, not just a query)

select * from foo where foodate >= getdate()- ?
where the variable for the data is set to 2.

And the package really did not like when I tried to do the following:
select * from foo where foodate>= dateadd(d,?,getdate) and used a -2 for the value. That time it threw all kinds of errors.

If I hard coded the number in, it returned the data that I wanted, but if I left it as a package variable nothing would work.

In the end I had to create a stored procedure passing the variable as a parameter in the SSIS package, and then things worked fine.

Oh well.

Note: Hopefully soon, I'll get several posts about how to from start to finish get a SSIS package running in Sql Server 2005.

Tuesday, May 15, 2007

It's a sad day.

Well, It's a sad day today. I knew this day was coming soon. But, my Beta fish, Phydeaux, died last night. I could tell something wasn't right. For the past few days, he wasn't eating well, and was just floating around the surface.

He was a good little fish: red, with bright fins. I'll miss him.

Monday, May 14, 2007

What a headache. . . linked servers and remote connections.

What a headache this has been. I've been trying to setup an SSIS package to run nightly for updating some data on a couple of our servers in development. After researching as to why I wasn't able to run the remote connection from our Sql Server 2k5 to Sql Server 2000. I finally generated this error:
Cannot obtain the schema rowset "DBSCHEMA_TABLES_INFO" for OLE DB provider "SQLNCLI" for linked server "FOO". The provider supports the interface, but returns a failure code when it is used.

and found the solution here http://support.microsoft.com/kb/906954


A little package that should have been run when the service pack was updated, but it didn't. I noticed that this is an issue with SP3 and SP4... too bad they didn't catch it in SP3 for the SP4 update. (though to be fair, they may not have known the package wasn't executing on the SP until people caught it with 64bit Sql Server)

Oh well. Hopefully, this will fix the error.

Thursday, May 10, 2007

Cool features of VMWare Workstation 6

Well, my friend found a really cool feature of VMWare workstation 6. It has a built in VNC server. So leaving the VM up and running, you can head home, and using a VNC viewer, you can now connect up to the VM and start working.

That will be a nice feature to use, so whether I'm at home or on vacation, if I have internet and a VNC viewer, I can still get to my desktop and keep working. I'm not sure what flavor they use, but it would be nice if they allowed for blanking the monitor and mouse like UltraVNC does.

Next Version of Sql Server: Katmai

http://www.microsoft.com/sql/prodinfo/futureversion/default.mspx
It looks as though Microsoft just announced their next version of Sql Server, code name Katmai.

From their site:
SQL Server code name "Katmai," the next release of Microsoft SQL Server, provides a comprehensive data platform that is secure, reliable, manageable and scalable for your mission critical applications, while enabling developers to create new applications that can store and consume any type of data on any device, and enabling all your users to make informed decisions with relevant insights.

Wednesday, May 9, 2007

VMWare announces new version

VMWare just released version 6 of workstation and version 2 of player:

http://www.vmware.com/products/ws/

Currently, I have their free server running all of my development VMs on a nice external hard drive. That makes life really easy for bringing your work home... which might not always be a good thing.

It even works on Vista. I had a co-worker just get a new machine with vista 64 on it, and it works great.

Tuesday, May 8, 2007

VMWare Ctrl-Alt-Del

For those of you out there using VMWare, and are frustrated with the whole Ctrl-Alt-Del popping up the message that "VMWare has detected you pressed Ctrl-Alt-Del...." when you lock your host machine, I've found the answer. It appears that in VMWare workstation you can set a flag to ignore that.

Add to the file Buried in C:\Documents and Settings\All Users\Application Data\VMware\VMware Server\config.ini the following:

mks.ctlAltDel.ignore = "TRUE"

and it'll ignore when ever you press control alt delete keys. Yeah! no more popups. For me, this has been working on VMWare Server 1.0.1 and since, and it's universal to every one on the computer.

Monday, May 7, 2007

An amazingly addicting game

So recently I've been spending my lunch hours playing a fun little game called Desktop Tower Defense.

This addicting game is way too much fun. Basically, you build a maze to shoot the baddies that move across the screen, or fly overhead before they can make it across. It's a great time waster, and I recommend, playing some of the challenge 4 minute games so as to not waste too much time playing.

Windows form Z-Order

An acquaintance on the Boise Software Developers group asked about finding the Z-Order for a control in a windows form last week. After a bit of searching, I found this for him. I figured, I'd put it here for anyone else who might need it:

int i = this.Controls.GetChildIndex(this.Label1);

While I'm not a windows form programmer, this should work. Just iterate through all the controls.

Wednesday, May 2, 2007

Converting a Column to a delimited string

Well, after a good bit of searching, I found a couple ways to convert a column of data to a delimited string. It's actually not too bad.

DECLARE @p_str VARCHAR(2000)
SET @p_str = ''
SELECT @p_str = CAST(O.OrderID AS NVARCHAR(6)) + ',' + @p_str
FROM (select OrderID
from Orders
where CustomerNumber = @CustomerNumber
) O


You have to set the @p_str to '' or it'll return a null. The other thing is that this method ends with a , that you may or may not have to trim.

The other method is this:

DECLARE @p_str VARCHAR(2000)
SELECT @p_str = COALESCE(@p_str + ', ', '') + CAST(OrderID AS varchar(5))
FROM Orders
WHERE CustomerNumber = @CustomerNumber

The second method does not need to have the @p_str set to '', and it doesn't end with a comma. So in the end, the second is probably the better method.

Tuesday, May 1, 2007

Gridviews, Excel and Ajax headaches

I'm working on a report that dumps out a gridview to excel. We are using the ajaxtoolkit, and I had wrapped the link to export the Gridview inside of an update panel with other various links to dynamicPdf reports. Well, unfortunately after a lot of searching, hair pulling and frustration. I found there is no way to contain the link inside an update panel because ajax raises an exception on the HttpResponse object. Bummer.

In the end, I guess it doesn't matter that much because I just have the spreadsheet save to the users desktop, and I don't display it inside of any panels.

If anyone has a work around for keeping the link inside the update panel, that would be great. I did find a function that would attempt parse the response string, and format it for ajax; however, I was never able to get beyond the errors.