|
As for #2...
Have you tried using a SynchronizationContext object to marshal the call to the correct thread?
In the UI thread set your myContext = SynchronizationContext.Current;
Then when you need to make that cross-thread call you do
myContext.Post();
Inside the Post you have to give it a callback method (I can't remember the name...I let intellisense remember for me :P ), along with an object which is sent to the callback method
in the callback method is where you actually change your UI object...
This works nicely for me.
The other two options are the one you tried, and using an AsyncOperationManager object, I like this one though.
|
|
|
|
|
This isn't about the database side of it - it's about the code that was generated.
In a web site, another developer used the table adapter wizard to create some queries. Here's one of the generated blocks of code (he's using a stored procedure in Scalar mode):
public virtual object InsertMyThing(string MyThing)
{
System.Data.SqlClient.SqlCommand command = this.CommandCollection[1];
if ((MyThing == null))
{
command.Parameters[1].Value = System.DBNull.Value;
}
else
{
command.Parameters[1].Value = ((string)(MyThing));
}
System.Data.ConnectionState previousConnectionState = command.Connection.State;
if (((command.Connection.State & System.Data.ConnectionState.Open) != System.Data.ConnectionState.Open))
{
command.Connection.Open();
}
object returnValue;
try
{
returnValue = command.ExecuteScalar();
}
finally
{
if ((previousConnectionState == System.Data.ConnectionState.Closed))
{
command.Connection.Close();
}
}
if (((returnValue == null) || (returnValue.GetType() == typeof(System.DBNull))))
{
return null;
}
else
{
return ((object)(returnValue));
}
}
I recently added the same thing to a project I'm working on. Here's my code:
public virtual System.Nullable<int> InsertMyThing(string MyThing)
{
System.Data.SqlClient.SqlCommand command = this.CommandCollection[1];
if ((MyThing == null))
{
command.Parameters[1].Value = System.DBNull.Value;
}
else
{
command.Parameters[1].Value = ((string)(MyThing));
}
System.Data.ConnectionState previousConnectionState = command.Connection.State;
if (((command.Connection.State & System.Data.ConnectionState.Open) != System.Data.ConnectionState.Open))
{
command.Connection.Open();
}
object returnValue;
try
{
returnValue = command.ExecuteScalar();
}
finally
{
if ((previousConnectionState == System.Data.ConnectionState.Closed))
{
command.Connection.Close();
}
}
if (((returnValue == null) || (returnValue.GetType() == typeof(System.DBNull))))
{
return new System.Nullable<int>();
}
else
{
return new System.Nullable<int>(((int)(returnValue)));
}
}
</int></int></int>
When he calls his adapter function, he uses the following:
int id = Convert.ToInt32(adapter.InsertMyThing(MyThing));
When I try that with MY adapter function, I get an Invalid Cast exception.
If you haven't already noticed, the return type is different in my version of the function, yet we both used the adapter wizard to create the queries, and we're using the same database/stored procedures.
What's going on here?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Can you even cast a System.Nullable to an Int32 ?
---modified
I tried something similar and the compiler barks at me that I cannot return a static type System.Nullable
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
My real question is why does the same wizard output different code? The return types are the only difference.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Strange. Got me on that one
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
John Simmons / outlaw programmer wrote: What's going on here?
Different drivers?
Different IDE (Wizard) versions?
John Simmons / outlaw programmer wrote: and we're using the same database/stored procedures.
The same instance or copy?
Something somewhere must be different yes?
led mike
|
|
|
|
|
I have a class lib - let's call it Lib1.
I have a class lib that uses Lib1 - let's call it Lib2.
I have an app that references Lib1.dll and Lib2.dll in their respective bin/debug folders - lets call it App1.
When I make a change in Lib1 or Lib2, I have to remove all references to the changed lib, and do a build all - let's call that bullshit.
Someone please tell me I'm missing some elegant aspect of .Net that makes sharing code between projects easier.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I've not experienced any problems with my Common library.
When i make changes to it, i place the new copy in a shared Release folder that is referenced too by all using apps, and the new functionality shows up in my application without any need to do a re-build.
Are you referencing the projects directly from their respective bin folder or including them as existing projects?
Tris
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
I'm referencing them from the bin folders.
The primary problem appears to be that when you do that, a copy of the DLL is put into your project's bin folder, but apparently only if it doesn't already exist there.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
From what i know, CopyLocal copies it to your output directory, which you have to do if it isn't loaded in the GAC.
I don't know why its working for me.
Could this be a WTF?
T
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
Perhaps not a .NET thing but a VS one. I think there are many approaches. One that I like to use frequently is to add the project to the solution rather than just referencing the binary from a folder. There may be drawbacks to that you don't like but at least try it to see if it works for you.
led mike
|
|
|
|
|
putting all related projects in a single solution must solve it for sure.
However in my experience (it has been discussed on one of the forums too) in VS2005 it typically
causes too much rebuild activity when something got changed. I'm not sure that got fixed in VS2008.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Luc Pattyn wrote: it typically
causes too much rebuild activity when something got changed.
Depends on your definition of "too much" I suppose. One could also choose to just have some cheese with their whine right?
led mike
|
|
|
|
|
You can change the build output path of the class library projects to output to the bin folder...and not into debug or release folders under the bin folder. This way, you can reference that ONE build of the class library and not have to rereference all the time. That's as long as you don't need both the debug/release versions stored there.
Hope this helps.
|
|
|
|
|
That's fine until you go to use the same class library in another project. Then you have to play musical directories for the new solution, thus breaking the previosu solution that also uses the class library.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
our project tree is arranged as follows:
src\
bin\
debug\
release\
lib\
classlibproj1\
classlibproj2\
etc...
now .SLN files go into 'src'
each .csproj goes into it's respective folder, but we change the output to so that it goes into src\bin\debug or src\bin\release depending on the build.
all external "binary" library references come src\lib
but we only put "external" or third-party binary libraries into src\lib (libraries from outside or above the 'src' tree).
if there's a dependency between projects under the 'src' tree, then put them into the same solution file (.sln) and make a reference from one to the other.
if Proj1 and Proj2 are independent of each other, but use one or more common libraries that can have different versions, then you need separate src or bin locations for them and separate 'lib' locations.
hope this helps.
Silence is the voice of complicity.
Strange women lying in ponds distributing swords is no basis for a system of government. -- monty python
Might I suggest that the universe was always the size of the cosmos. It is just that at one point the cosmos was the size of a marble. -- Colin Angus Mackay
|
|
|
|
|
Hi every body.
Can any body help me plz
I have a task that requires to read the text on a image
My requirement is
I take a image of a vehicle number plate through a web cam or a usb camera.
Now when i get the image when i click a button i should get the numberplate number into a text box I need this functionality using c# or vb.net plz help me i am doing my B.tech final year project, I would be very much thank full if any one will help me
thanks in advance
with regards
harivinod
|
|
|
|
|
You posted your question in 4 different forums huh? How rude. Read the forum rules. All this time you spent cross-posting, and waiting for someone to reply, you could have done research to get the answeres yourself.
I'm going to become rich when I create a device that allows me to punch people in the face over the internet.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
|
|
|
|
|
Justin Perez wrote: posted your question in 4 different forums
I just wondered how many times I'd see that garbage.
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
Paul Conrad wrote: I just wondered how many times I'd see that garbage.
Yeah, really. I don't think we have seen the end of it though. No one is going to answer his posts, and he will never figure it out for himself. So, I'm guessing he will be crop-dusting our forums with crap for the next week or so.
I'm going to become rich when I create a device that allows me to punch people in the face over the internet.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
|
|
|
|
|
How many forums did you spam with this garbage? Don't cross post.
"What's your question? All I see is some deranged, half-assed looking run-on sentence. Where are you having problems?" - Justin Perez
|
|
|
|
|
harivinod wrote: plz help me i am doing my B.tech final year project
First question - is it urgent?
Essentially, you're asking us to do your homework for you? Silly little lazy Indian...
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: you're asking us to do your homework for you? Silly little lazy Indian...
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
harivinod wrote: plz help me i am doing my B.tech final year project
How does come into the picture of your problem description?
harivinod wrote: full
How do you measure it or whether it is half or quarter? Which metrics are you trying to use? Gallons or Litres?
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
I'm trying to add a reference to a web service on a remote sharepoint 2003 server and I keep getting an error:
There was an error downloading 'https://portal.example.com/site/_vti_bin/usergroup.asmx'.<br />
<br />
The request failed with an empty response.
It comes up with a description that looks right in the web page view though. Here's a quick screenshot:
http://i223.photobucket.com/albums/dd58/armo_2007/webservice.png[^]
I'm connected to the Internet through a proxy, could this be the issue? Or security on the server?
It's my first time using a web reference so I'm probably doing something stupid, any help would be appreciated.
|
|
|
|