|
I have a multithreaded .NET app that I would like to use a single threaded ActiveX control in. Unfortunately, this causes an exception as I would expect. However, I was wondering if there is a workaround for this?
I cannot change the app from MTAThread to STAThread since it is using sockets for communications and needs the multiple threads for comms, and the single threaded ActiveX control is Adobe's flash control (in order to play a flash movie).
So, like I said, is there a workaround for this somehow?
Thanks,
David
|
|
|
|
|
Hi,
this is what I would attempt:
create a new thread, call Thread.SetApartmentState (only once!) and only then have it access your ActiveX.
if you need multiple threads accessing the ActiveX, AFAIK you have to proxy that and let only the one thread do the work.
Luc Pattyn [Forum Guidelines] [My Articles]
- 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 the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Perfect - that worked like a charm. Created a delegate, stuck my dialog instantiation inside of the delegate, created a thread using the delegate, and set it to STA.
Thank you very much!
|
|
|
|
|
i am writing a stored procedure for this purpose only .
"i have a table of messages , i need the data base to notify my windows service that a scheduled message would be sent now , transfering at least the message id to the windows service"
i tried to use .net Remoting for that purpose but i figured out that .net remoting namespace can't be included in such a solution .
then i tried to use sockets to open ports through the data base to the windows service that exist on the same machine that will listen for incoming data from that clr stored Procedure . i successfully made that second choice but the problem with that , when i try to invoke the send method of udp client , it gives me an exception of socket exception
tells me socket permission request had failed , how can i grant socket access to the CLR Stored Procedure
knowing i tried to configure the code access security configuration manager in the administrative tools but in vain
anyone knows how to solve that problem either that of sockets or give me a whole new solution to the above problem
would be great
thanks in advance
Human knowledge belongs to the world.
|
|
|
|
|
I would probably forget the manually socket solution you came up with and look into SQL Server Notification Service.
|
|
|
|
|
How about using MSMQ. Thus the db can send a message to the que using CLR integration in the SQL db, and the service can pick it up from there.
alex_nel
|
|
|
|
|
Depending on what information he needs to convey to the clients, that's possible. Notification services can be more appropriate and has a lighter overhead than MSMQ.
|
|
|
|
|
Im trying to reinstall net framework 2 on my vista pc,but im told that its already preinstalled,but when i try to install a software program,ie sony media manager,i get an eror saying recent net frame work 2 is most current verion and instaltion can not continue.
Is it possible to use my vista upgrade disk to repair net framework 2,or is there another way around it.
Ive already tried the "sfc" command but that brought back nothing untold.
Any help would be most welcome
|
|
|
|
|
|
hi
I want to connect to a sqlserver instance on another computer in the workgroup network.
my program is win application with c# VS.NET 2008 and SQL Server 2000.
what settings are needed for my sqlserver instance and my application?
can you help me?
H.R
|
|
|
|
|
You need to create a Login on the sql server, apply permissions to it (Server roles, User Mapping, etc) and then in your application create a connection string for that server, e.g.
string ConnectionStr = "data source=FriendsServerName;initial catalog=TheDataBase;User ID=YourLogin;Password=12345";
Using that connection string connect to your friend's sql server.
That should do the trick.
It does on SQL Server 2005 anyway.
var question = (_2b || !(_2b));
|
|
|
|
|
thanks, I did them but I could not to connect.
----------------------------------
my application: VS.NET 2008-C#
my DB: SQL Server 2000 Personal Edition
my OS: Win XP Profesional sp3
----------------------------------
I have done these steps:
1. in target sql server instance: Enterprise Manager -> server -> right click -> Properties -> Connections tab -> tick:
-allow other sql servers to connect remotely to this sql server using RPC
-enforce distributed transactions
2. in target sql server instance: Enterprise Manager -> server -> right click -> Properties -> General tab -> Network Configuration... button ->
enabling TCP/IP
3. in target sql server instance: Enterprise Manager -> server -> right click -> Properties -> Security tab -> Authentication ->
SQL Server and Windows
4. I created a New Login in target sql server instance:
Name=admin , Password=1001 , SQL Server Authentication , Database=Exam
5. my SqlConnection in application:
"Server=192.168.0.205\\MYSQLSRV; Initial Catalog=Exam; Integrated Security=False; Persist Security Info=False; User ID=admin;Password=1001";
6. I removed anti virus softwares and turned off Windows Firewall.
7. I tested both of my computers to ping to another
But yet I have an error:
an error was occured while establishing a connection to the server. when connecting to sql server 2005, this failure may be caused by the fact under the default settings sql server dose not allow remote connections.
(provider:sql network interfaces, error:26-error locating server/instance specified)
----------------------------------
can any one help me ?
H.R
|
|
|
|
|
Erm, it seems fine, except:
H.R wrote: 5. my SqlConnection in application:
"Server=192.168.0.205\\MYSQLSRV; Initial Catalog=Exam; Integrated Security=False; Persist Security Info=False; User ID=admin;Password=1001";
Well, that should be your connection string, not the actual connection, as in:
private void ConnectToDb()
{
SqlConnection sqlConn = new SqlConnection("Server=192.168.0.205\\MYSQLSRV; Initial Catalog=Exam; Integrated Security=False; Persist Security Info=False; User ID=admin;Password=1001");
sqlConn.Open();
sqlConn.Close();
}
Test it like that.
If this is how you used it, though, I honestly do not know what is wrong.
One more thing... i understand you added a login to the server instance... but DID you actually add a user to the database you want them to use?
You'll find a "Users" folder in Databases/YourDb/Security/Users
That should help. I think.
var question = (_2b || !(_2b));
|
|
|
|
|
Hi
I am making a .NET program (C#) and are using a Tab Control with 3 tabs...however, when I hover the tabs I get a flickering effect. Anyone know how to fix this? is this a bug with the control?
|
|
|
|
|
Be sure that you have double buffering for the form set to true.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my Blog
|
|
|
|
|
Setting doublebuffered on the form did not have any effect. However, the following code did clear up this and other repaint issues easily:
protected override System.Windows.Forms.CreateParams CreateParams
{
get
{
var cp = base.CreateParams;
cp.ExStyle |= 0x2000000;
return cp;
}
}
I find it really strange that this isn't enabled by default from Microsoft since the TabControl looks like crap without it, and there are no apparent downside of using the fix above except that you get a bit more memory usage and a few more lines of code.
Please, if possible, enlighten min why Microsoft decided to drop this option as on by default? For the record; it sets the WS_EX_COMPOSITED Window property. In MSDNAA I can't find any information indicating why this is not enabled.
|
|
|
|
|
Hi,
I have a problem backtracing which .Net transaction is blocking another transaction.
I would like to find which .NET transaction is blocking another .NET transaction. I can find the locks in SQL Server 2008 and it's corresponding SQL Server transactionids, but I cannot map the .NET transactionids to them.
In the sys-tables of SQL Server 2008, I find the transactionids of the blocking transaction and the transaction that is being blocked. (eg 75288) When I retrieve the transactionid from within my .net application through 'System.Transactions.Transaction.Current.TransactionInformation.LocalIdentifier.ToString()', it's a guid. I expected the transactionid of sql server and .Net transactionid to be the same, so I could backtrace to the blocking transaction in .NET and resolve the locking problem.
Can anyone help me with this? Thanx.
Kind regards,
Webster
|
|
|
|
|
Well, for one, a .NET transaction from System.Transactions is not specifically a database transaction. Its a .NET transaction, which may involve many resource managers, including SQL Server, but not limited to it. Its entirely possible to have a .NET transaction that doesn't involve SQL Server at all. So there is unlikely to be any correlation between the transaction ID for the .NET transaction and the transaction ID for the SQL Server transaction, I wouldn't try to use any comparison between the two to find a match.
As for a solution to your problem...you probably need to use a profiler that will trace your calls and identify blocks. I am not sure if either of these will take you directly to the source of the problem, but they are both pretty advanced and should help:
JetBrains dotTrace Profiler
RedGate Ants Profiler
|
|
|
|
|
Can any one suggest me how to connect the database using vb.net 2008.
|
|
|
|
|
e.g.,
string connstring = "Data Source = .\\ABC;Initial Catalog = XYZ; Integrated Security = True";
SqlConnection conn = new SqlConnection(connstring);
SqlCommand comm = new SqlCommand();
comm.CommandText = "Select * From DummyTable";
comm.Connection = conn;
conn.Open();
comm.ExecuteScalar();
conn.Close();
MSDN[^]
|
|
|
|
|
There is not just one or two ways to do this. I highly suggest picking up a book on ADO.NET to have as a learning tool and reference.
|
|
|
|
|
I am new to development. Could anyone suggest,what are the different downloads I would have to do,to start learning c# on the .NET framework?
|
|
|
|
|
If you have .net, you have all you need. The framework includes CSC, the command-line compiler for C#.
I suggest you open a DOS box, write a "hello world" console app, and compile it.
|
|
|
|
|
|