Monday, August 30, 2010

Fiddler and Android SDK

So, I've been trying to get my android emulator to talk through fiddler. I've run through all the settings, command line options, and nothing seems to work. I ran across one quote that I suspect is true, in Android 2 it ignores any proxy settings and is broke. It works great in 1.5.

Even though we aren't using Android 2.2 OS, I decided, why not. Kick it off, tweak the settings, and sure enough, it actually works. Since what I'm needing to test isn't specific to 2.1 or 2.2, this is good enough for me. YMMV, but try it with 2.2 and it should work. (if only Google would go back and fix 2.1)...

Thursday, August 26, 2010

Custom Membership Provider in winforms

So, I've been tasked to create users on one system into another. No prob. I just create a simple console app, add our custom membership provider to the right config section, borrow some code from another app, and loop it. Whee....

... Until, that is, I kept getting the error, Unable to find XXXX.Membership in System.Web....

There's all kinds of references of how to use the default membership provider in a winform or console app, but not much on a custom membership provider. After a good bit of digging, I found this blog: http://geekswithblogs.net/Shadowin/archive/2007/04/05/110864.aspx

I failed to put ", AssemblyName" in the reference in the config. So it was defaulting to System.Web.

Your entry for the custom membership provider should look something like this:


< add name="AspNetSqlMembershipProvider"
type="XXXXWeb.Security.CustomMembershipProvider, XXXXMembership"
connectionstringname="SiteSqlServer" / >

Wednesday, July 28, 2010

'standardEndpoints' cannot be read because it is missing a section declaration

I just tried to publish my first WCF RESTful service to our 2k8 box, and hit the wall with the following error:

The configuration section 'standardEndpoints' cannot be read because it is missing a section declaration


Well, after much searching, trying different options, reconfiguring, reading documentation, I finally found a post that should clear it out:

NET 4.0 Beta1/Beta2 Web Application Configuration section missing declaration error

http://support.microsoft.com/kb/958854/en-us

Appearently, on a windows server 2008 box, most .net 40 stuff works (well stuff that I've tried), but a couple of the items were missed. I didn't see an sp2 for win2k8 in the updates, so I downloaded and ran the HotFix. And what do you know? That worked. I've seen a bunch of posts on how to fix this error. This might just be the solution you're looking for.

Tuesday, June 29, 2010

Okay... i've been busy...

Currently, I'm working on a new project using asp.net MVC 2, StructureMap, and all those goodies. I just ran across a nice blog that combines all those, plus some:
Maintainable MVC series.

The main point was this little nugget, that I figured out on my own, but would have been nice to know about in the beginning:

If a class is created by StructureMap it defaults to the constructor with the most parameters.


Oh well. Even though it takes longer, you often remember things better when you have to struggle to find the answer than it being given to you.

Thanks anyways!

Wednesday, August 19, 2009

Windows 7 BSOD

Hey!  I’m so excited!  I thought they got rid of the blue screen of death with Vista (though those reports were vastly over exaggerated).

 

I got my first BSOD in Windows 7 the other day, and I thought I’d post a screen shot for all to see:

 

BSOD_Win7_VM

Of course, I was only able to get the BSOD from windows 7 running in a VM.

Monday, June 15, 2009

CHM files and Vista

I’m working on installing on a new server, TFS 2008, and in the setup directories there is an Install Guide.  Being the diligent (for once) developer, I opened it up, and it said to download the latest install guide giving me a link. 

However, after downloading the new chm file from Microsoft, it wouldn’t open.  On one system, it said to check my dns server.  and on my host Vista system, it just wouldn’t display.  I opened up IE, checked the local intranet settings and didn’t see anything there.

The solution?  I right-clicked the file, and noticed that there was an Unblock button.  After clicking that, it opened just fine.  Apparently, Vista was preventing me from viewing the web pages inside the help file because they came from a different zone.

 

Once unblocked, the button no longer shows up, and I can read it just fine.

Friday, June 5, 2009

Stored Procedure taking forever.

Today, I came across an issue where from Sql Server Management Studio, a stored procedure was taking forever to run.  But from the application it was running just fine, and if I executed the sql from within the proc on it’s own, it ran just fine. 

Luckily, a friend, Chris Brandsma had stumbled across this about a year ago, and posted it and a solution on Elegant Code.

http://elegantcode.com/2008/05/17/sql-parameter-sniffing-and-what-to-do-about-it/

It’s called SQL Parameter sniffing, and MS (as well as Oracle and the others) use it to improve performance of stored procs.  However, if you have a large or sudden variance in the number of rows returned, the proc will seem to “hang up.”

At least I know what the fix is, and what to look for if it happens again on one of those “random” timeout bugs.

Wednesday, May 20, 2009

VS2008 and SS Express 2008

If you’re running Visual Studio 2008 sp1 and Sql Server 2008 in Vista x64, then you’ve probably come across the error when creating a database:

 

“Connections to SQL Server files (*.mdf) require SQL Server Express 2005 to function properly. Please verify the installation of the component of download from the URL:

http://go.microsoft.com/fwlink/?LinkId=49251”

 

It took me several days with no real solution until I found a reference to http://support.microsoft.com/kb/957944 

Apparently there is a bug with VS2008 and Sql Server Express 2008 in that some of the files aren’t properly registered, so it doesn’t realize that you have a valid sql server install.  And to make matters worse for finding the solution, it only happens if you are using x64 everything. 

 

You’ll have to email Microsoft to get the Hotfix, or install 32bit sql server express.

For me, the Hotfix did work.

Monday, May 18, 2009

nunit and VS2008

I’ve recently started using NUnit on some of my side projects, and the one frustrating thing has been the lack of ability to debug the unit tests. 

I know, I can see the “run” external app on the unit test project to point to the nunit directory, or I can run nunit, manually attach to process, etc.  But those seem kinda hacky.  Or I could shell out money for other solutions.

Well, codeplex has once again saved the day:

 

NUnitit is a project that adds a new tools menu that will allow you to debug VS projects in NUnit without having to set the execute remote, or attach process.  It in will auto detect the NUnit install, so if you have NUnit installed in a different directory, you’ll still be fine.  And you aren’t forced to always use NUnit.  You can set your projects up for MSTest and NUnit and be able to debug both.  I hope it’s

Friday, May 15, 2009

Top 1 in a subquery…

So I came across an interesting sql problem.  I have a list of devices that could have multiple customers attached to the device.  And on the admin page, i need to list the devices and at least one customer attached to the device.

I didn’t want to display multiple rows in the table each with the same device but multiple customers.  This is how I solved it:

select * 



from devices d left outer join customers c on d.id = c.deviceid 



        and c.id = (select top 1 id from customers where deviceid = d.id)




 



The first left outer join, insures that if i have a device with no customers, I’ll still get the device results back.  If I have multiple customers, I’ll get the first one returned.  I could put other “filtering/sorting” in the subquery if i wanted, but this seemed to work enough for my purposes.

Thursday, May 14, 2009

Bugged by FindControl….

 

I’ve always been bugged by the “FindControl” method on the Gridview, or any part of the page (I mainly use it on a gridviewrow after selecting).  So I wrote a little Generic method.  This can be added to a utilties class, or just on the codebehind page itself:

 

   1: public T FindControl<T>(Control searchControl, string controlId) where T : Control {



   2:         return (T)(searchControl.FindControl(controlId));        



   3:     }




To use the new FindControl:





   1: Label foo = FindControl<Label>(gvTest.SelectedRow, "myIDLabel");




This is instead of doing something like:





((gvTest.SelectedRow).FindControl("customerId") as Label).Text




Well, at least it seems cleaner to me in code.  I’m sure that there are better ways, but this works for me for now.

Tuesday, May 12, 2009

Amazing tool for VS 2008 and Sql Server

I was just told by a friend that I need to check out what he called “Data Dude”, which is an add-on for Visual Studio 2008. 

It adds a Database Schema compare so that you can compare two different databases.  I ran it on our beta db and dev db, and found several differences that I didn’t expect. 

Everything from triggers, indexes, columns, etc. 

dd1

It’ll let you drill down into the dependencies, allow you to make the updates, or create new items, etc:

dd2

You can easily see the differences:

dd3

Here’s the Link:

http://www.microsoft.com/downloads/details.aspx?FamilyID=bb3ad767-5f69-4db9-b1c9-8f55759846ed&displaylang=en

Windows Live Writer

My first post from windows live writer.  This is suppose to make blogging easier.  So we’ll see. 

 

http://download.live.com/writer

 

Update:  Adding plug-ins are cool.  I’ve added a code snippet, and this is what it looks like for formatting:

   1: foreach(bar b in foo) {



   2:  b.SayHello();



   3: }






And this is what the Code Snippet window looks like:



image



You can copy and paste images from the clipboard (as I just did), and this makes blogging awesome. 



 



So 2 cool tools today!

Wednesday, April 22, 2009

How to Resize a VMWare Disk

I use VMWare, and one problem is that the default save being 16gb often runs out of space. After googling for an easy method for increasing the size, I've found several solutions involving using Linux boot CDs, tools etc. This is how I did it:

First, use the VMWare command*:

C:\Program Files (x86)\VMWare\VMWare Workstation\vmware-vdiskmanager -x 32Gb "x:\Dir\DiskFileName.vmdk"

Or where ever your VMWare workstation is installed
This will increase it to 32gb

Then go to http://www.partition-tool.com/personal.htm and you can use their free version to increase the primary drive.

the free version only supports 32bit OS, so if your vm is 64, you might look at mounting the linux iso at www.sysresccd.org to increase the partition.

Hope that helps.

* one thing to note, I read somewhere that you should not have any snapshots of the drive sitting out there. Also, back everything up first before trying (I made full clones, just in case).

Tuesday, September 2, 2008

A nifty program...

Here is a very nifty site for formatting code for HTML:
http://www.manoli.net/csharpformat/

what makes this really good, is that you can nest the css into the document, so for sites where you can't link the css, you can still use it.

I use the output of this for our internal wiki with sql.

Here is a screenshot of the output : (unfortunately, blogger is overriding the css)



So, hopefully someone can tellme how to override the css in blogger, so that it works. However, for the Sharepoint Wiki that we use, it's great.
And the source is available, so that you can fix some of those bugs, such as no space after a -- causes the comment to not be formatted.

Monday, June 9, 2008

remote webservice debugging

I was given this link by a friend, that shows how to enable the debuging forms for webservices in an app: http://geekswithblogs.net/juang/archive/2005/11/28/61437.aspx

All you have to do is add:

<configuration>
<system.web>
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
</system.web>
</configuration>


to your web.config and now you can call the webservice from a different machine and get the test form. Now you don't have to have fiddler installed on your servers to view info.

Wednesday, April 9, 2008

Vista USB Drive Annoyances and a Solution

I'm not sure if it's Vista64, VMWare, Maxtor, or something else entirely, but over the past 9 months, I've had an working, not working issue with the "Safely Remove Hardware".


I run VMWare workstation on my External Maxtor Turbo edition Drives. They run all my development tools in xp. And my base os of course is Vista 64 Business edition. Well, depending on the version number of VMWare, for a while, I was always able to Safely remove the drives after shutting down all of my vms and exiting the program. However, a couple weeks ago, I installed an update to VMWare as well as SP1 to Vista. Oh, and I added a docking station to the mix as well.



Now it seems that I can't ever safely remove the drive. To remedy the situation, I closed down all the programs I had open, killed tasks but to no avail, it still doesn't work. The only way to remove it is to shutdown the computer.


Are there alternatives out there? Appearently there are. I found a nifty program called USB Safely Remove at http://safelyremove.com/ and their program actually does what Microsoft should have offered in the beginning. It tells you what programs are running against the drive if it's unable to remove the hardware. That is a really nice feature.






What I also like about it, is that it hides itself in the task bar, replacing the windows remove icon, so I don't have to run a separate program. The interface is a lot cleaner, and fewer clicks to find what devices I want to remove.


With the program, I was able to find that my Maxtor drive had a process using it with different admin level that what's current running has access to the drive. And that's why I'm not able to remove it. My other USB devices show up fine and can be removed without a problem. And I don't end up with the generic "This device is in use" message. I actually get something kind of handy.


Here is a link to their usage guide. http://safelyremove.com/scr_guide.htm


Another thing that I like, is that they have a ton of options. You can force a device to shutdown. And you can even build command line scripts! You can change icons for each of your devices, hide or show devices in the list, and it tells you how many are currently hidden. The interface is intuitive and clean. They also appear to be updating every month or two, so you know the developers love there program, and are constantly trying to improve it (that means a lot to a fellow developer like me).


So, if you find yourself often getting the can't remove device now, use this program. You'll be able to figure out what is causing the lock on the drive, and be able to remove it quickly.


It's pretty inexpensive, and it will save you a ton of headaches if you swap out a lot of usb devices. You can download it for free and get a 30 day trial.






Tuesday, March 18, 2008

Team Foundation Server 2008

I have a fresh install of Windows Server 2k3, just installed Sql Server 2k5 and Sql Server SP2. I'm getting ready to install Team Foundation Server 2008.

And then I get the ubiquitous error: 320000


The Commandline '"C:\...\TFRSConfig.exe" /setup /install /s "servername" /u "NT Authority\NetworkService" /buildInIdentity /l "1033" /verify /ignoreExistingIISArtifacts /instancename "MSSQLSERVER" /appPoolName "ReportServer" /reportServerUri "http://localhost/ReportServer" /reportManagerUri "http://localhost/Reports" /h "servername"' returned non-zero value: -2147022676.

I've seen other sites with this, tried the click retry 4 to 8000 times, and nothing. I finally killed the install. Then I remembered, when I was installing Sql Server and IIS i had switch a flag for some other error I was getting in IIS:

The fix was to go to open IIS, right click on Web Sites, select properties, select service tab, then check Run WWW service in IIS 5.0 isolation mode.

Figuring that there wasn't much else I could do, I unchecked that field, and went back through the TFS install.

What do you know? It worked. (oh and I had to restart IIS).

So, at least I've gotten it installed. Now to play with it.

Tuesday, March 11, 2008

1 old and 1 new feature of Gmail.

Official Gmail Blog: 2 hidden ways to get more from your Gmail address

I just found on the GMail Blog two neat features you can do with your gmail addresss. One I've known about for years, and that is using a period in your email address. so example@gmail.com is the same as ex.amp.le@gmail.com, and you can use that to figure out where spam is coming from, if you place the period in different places of your email. That's of limited use, unless you want to be spiffy any have a period separating words in the email address. The other item that I didn't know about and was really interesting was using the + in your email. So you can send email to exampl+orders@gmail.com. Then create a filter for the +orders and have all your orders labeled. I've started using +spam, +orders, etc. I then know if someone starts to sell my email address to other companies, I can just start blocking the +.

I use this with my google domain email, and it works great!

Monday, February 25, 2008

cwbx info on connection pooling

Well, I talked on the phone with IBM's .net Support. And the cwbx definitely does not do any kind of pooling. It's a batch/queue setup. So multiple calls into the dll will stack up one after the other until they are all done.

To get around this I created a simple Object Pool, that would instanciate the object's connection to the 400, and then when I need the object, get it from the pool, use it and return it. Pretty slick!

As for the connecitons on the 400, they just sit in a status of TIMW until they are used. I do have a limit on the number of connections in the pool, so if I get too many in there, I close the oldest one down.