[SOLVED] Winforms .NET Application Slow to Load When There is no Internet Connection

Background Info

Here is a rather strange behavior I saw when I deployed a .NET application onto a PC: It takes about a whole minute for my main form to show up! The machine is running Windows 7 on a 2.6G duo core CPU with 2GB RAM with no other applications running.

I’ve deployed the same software onto different PCs of same hardware and OS configuration, and the same software would load within seconds on PCs with internet connection.

I use Devexpress’s Winforms component for my applications, so I thought maybe it has something to do with checking for component license via the internet, but it couldn’t be. I paid for the components already!


Turns out it has something to do with Microsoft .NET’s authenticode signature checking, and without internet connection, you literally just have to wait for all the behind-the-scene process to timeout.

To disable signature authentication, open up your [application].exe.config file in your Program Files directory and add the following element under <configuration>:

              <generatePublisherEvidence enabled=”false”/>

NOTE: You may need to give WRITE permission to your application’s config file to make the edit.

NOTE: You will not see this slow loading problem if you are not using a signed 3rd party (in this case it’s Devexpress) component in your application.

You can read more about it here:


Handling “Concurrency violation: the UpdateCommand affected 0 of the expected 1 records.”

I came across a dreaded exception when using tableadapter to update a datarow:

Concurrency violation: the UpdateCommand affected 0 of the expected 1 records.

I pulled my hair out on this one – read up on concurrency violation and what could cause this exception. MSDN and stackoverflow users would tell you it’s due to a datarow being “detached” from the dataset, or somewhere in code you are doing an update to dataset and your copy of datarow is not the current one.

Whatever, not going to pretend I understand it. Not going to pretend I don’t have a hole in my code somewhere. I just want to update my record Goddammit!

So, here is what you do… go to your dataset designer, right click on the property of your tableadapter and expend on the UpdateCommand property. You’ll want to change the SQL query text’s WHERE cause to only match the primary key ONLY.

For example, the auto-generated update command may be:

UPDATE table
SET field1=value1, field2=value2, etc.
WHERE id=@original_id, field1=@original_field1, field2=@originalfield2…

All you got to do is change it to update row with a row ID:

UPDATE table
SET field1=value1, field2=value2, etc.
WHERE id=@original_id

Problem solved! No more concurrency violation exception, but this doesn’t mean you shouldn’t look for places in your code where concurrent updates may take place and put in some safety measures.

DataRowView RowState Unchanged {2} After Changing Item Value

Came across a very perplexing .NET behavior as I was working with a databound ListBoxControl.

I have multiselect enabled (SelectionMode = Multiextended), and the task was to loop through all list items, insert a new item in database after the last selected item in listbox, and write the new order index back to the database as we loop.

I am using the tableadapter.Update() method and testing return value of 1 for successful update. For some reason it updates fine up until selected item in the listboxcontrol (talk about weird!), and upon further digging I found the RowState isn’t changed after setting the new order index value to my data field:

vb.net rowstate unchanged

Further research suggests I’m not the only one who came upon this weird behavior. See:


The solution is to call EndEdit() method on the DataRowView to force RowState to Modified so the subsequent TableAdapter.Update() call will actually perform an update to the database:

vb.net rowstate modified after calling endedit