|
No. Everything will be Visible = False until the form is shown.
If you're relying on the state of controls to determine the state of your model your doing it backwards. The state data of your model should be kept in the model itself.
|
|
|
|
|
Windows App....
Problem is here "txt.Name" - Do not name your control "Name". I used to have the same problem, all control with "Name" as their names wont be visible at design time and their property will be change to false...
I remain joe!
|
|
|
|
|
Hello,
I am having some problems when running a C# application that I've written. It runs fairly smooth on a local
machine (test machine). However, when I am running this from a network drive, the responsiveness is slow. When
I click on a button that opens up a form, there is a considerable lag (5-10 seconds sometimes). Is there anything that I can do to speed this up on a network?
|
|
|
|
|
There is no generic method that will speed anything up. Code doesn't run faster or slower depending on where you ran it from. Code runs at the processor speed, not the network.
Now, any processing you have on data is remote locations or stored in files is where you'll run into problems with performance. Since we have no idea what you're code is doing when you "click a button that opens up a form", there is nothing anyone can tell you that is going to help.
We need more detail about EXACTLY what your code is doing when you run into this problem.
|
|
|
|
|
As Dave mentioned, you didn't give a lot of details so I'll take a stab in the dark and say that your "work" is probably being done on the UI thread rather than on a background worker or other type of thread. (If you have no idea what that means then you are definitely working on the UI thread.) That will kill UI performance if you start mixing long-running operations such as disk-based access or network-based access. Your UI will hang while it processes the work because there is only one guy in the room doing anything.
If this is the case, you will want to change your worker method(s) to use an async pattern so you can decouple the long-running work operations from the UI. That will keep things responsive... at least on the UI.
|
|
|
|
|
Hello everybody
I would like to cast a System.__ComObject to another type which is an interface. However, this interface is retrieved by reflection. I tried to create a generic cast method but it failed. I also tried to use TypeConverter class but it also failed. Even now, I try to use Marshal.CreateWrapperOfType but it seems to fail
Here is my code for moment
Assembly ctClientServerLib = Assembly.LoadFrom(string.Concat(bfcSetupFolder, "Interop.CtClientServerLib.dll"));
Type applicationClientClass = ctClientServerLib.GetType("CTCLIENTSERVERLib.CtApplicationClientClass");
Type ictSession = Type.GetTypeFromCLSID(new Guid("BCB06C70-AF26-11D3-8C89-00C04F517D7D"));
Type ictProtectedSession = ctClientServerLib.GetType("CTCLIENTSERVERLib.ICtProtectedSession");
Type ictSessionCtx = Type.GetTypeFromCLSID(new Guid("5F852A70-7E77-11D4-8CE1-00C04F517D7D"));
Type ictSessionClient = Type.GetTypeFromCLSID(new Guid("2C3444F9-ED6D-4700-B2EC-F665569FE830"));
Type ictProviderContainer = Type.GetTypeFromCLSID(new Guid("797BB105-AEDF-11D3-8C89-00C04F517D7D"));
Type ictProviderContainer = Type.GetTypeFromCLSID(new Guid("797BB105-AEDF-11D3-8C89-00C04F517D7D"));
object session;
object res;
res = applicationClientClass.InvokeMember("ConnectToServer", BindingFlags.InvokeMethod, System.Type.DefaultBinder, cacc, new object[] { "MyServer", "MyDataBase", new String[] { } });
session = applicationClientClass.InvokeMember("Logon", BindingFlags.InvokeMethod, System.Type.DefaultBinder, cacc, new object[] { "ADMIN", "" });
res = applicationClientClass.InvokeMember("Initialize", BindingFlags.InvokeMethod, System.Type.DefaultBinder, cacc, new object[] { session });
Type ictSession2 = ctClientServerLib.GetType("CTCLIENTSERVERLib.ICtSession");
Type ictSessionCtx2 = ctClientServerLib.GetType("CTCLIENTSERVERLib.ICtSessionCtx");
Type ictSessionClient2 = ctClientServerLib.GetType("CTCLIENTSERVERLib.ICtSessionClient");
Type ictProviderContainer2 = ctClientServerLib.GetType("CTCLIENTSERVERLib.ICtProviderContainer");
var session2 = Marshal.CreateWrapperOfType(session, ictSession);
var sessionClient = Marshal.CreateWrapperOfType(session2, ictSessionClient);
var sessionCtx = Marshal.CreateWrapperOfType(sessionClient, ictSessionCtx);
res = ictSessionCtx2.InvokeMember("SetSessionCtx", BindingFlags.InvokeMethod, System.Type.DefaultBinder, sessionCtx, new object[] { });
var providerContainer = Marshal.CreateWrapperOfType(sessionClient, ictProviderContainer);
object objectManagerClient = ictProviderContainer2.InvokeMember("get_Provider", BindingFlags.InvokeMethod, System.Type.DefaultBinder, sessionClient, new object[] { 1, -523387 });
.
Thanks for help ![Java | [Coffee]](https://www.codeproject.com/script/Forums/Images/coffee.gif)
|
|
|
|
|
Why are you doing all this manually? Can't you use tlbimp to generate an interop assembly and let Microsoft handle the plumbing?
|
|
|
|
|
Hi
Because I use API of a software and it is impossible to install 2 different versions of this software on a same machine
So some methods change depending of the software version. Maybe it is impossible to make this cast so I will find a workaround 
|
|
|
|
|
Casting unmanaged objects to managed objects is a daunting task even when things are working properly. And you aren't getting any help if the 3rd-party is changing method signatures between API revisions. That is a cardinal no-no for exactly this reason.
If I had to do this, I would use a mechanism similar to discovering and loading a plug-in at runtime. (And there are articles on CP on how to do that) I would create an interface library that defines a new interface that harmonizes the difference between the two API's. (calling it the harmonized interface) In my application, I would reference that library and use those interfaces in code. Then, I would use the tlbimp tool to generate an initial interop assembly or write my own interop assemblies that will wrap the calls to the specific API versions exposing an object that implements the harmonized interface. The connector libraries would then be responsible for the heavy lifting of marshaling the calls from the harmonized interface to the underlying API-specific objects. In most cases, this should be simply pass-thru type calls but where there are differences I would handle those in an API-specific way in each of these connector libraries.
At runtime, I would need code which detects the correct version of the outside API and loads the appropriate connector library instantiating my interop class(es). Since they implement the common, harmonized interface, my app code would be consistent and the specifics of the underlying API differences are handled in the correct connector library. Where needed, I would use the underlying API version I detected to call (or not call) certain methods on the harmonized interface as appropriate.
The advantage of this approach is that when the API vendor screws you again with a new version that breaks the current API, you can simply write a new connector library and everything continues to work. If new functionality is added, expand the harmonized interface, implement those new methods in ALL of the connectors, but throw exceptions in the ones where the underlying API doesn't support the new functionality.
|
|
|
|
|
It's a terrible way to go, but I do not see a better one.
Using the dynamic keyword in a common base class for some of the types of ThridParty may help reduce coding - but can lead to problems with some interfaces.
|
|
|
|
|
I am trying to develoop an application in c# using Aforge.dll but please anyone give me some idea how to make object (edge detect) through webcam so that i can find approx origina length and breadth
|
|
|
|
|
|
hi , im working on a website and i want to let the user add their img for their account .
i know one way for adding img into the sqldatabase and its the regular one to using the file stream and then sql parameter , i know that way so far .
but do we have any other way for adding img into sql database without using the sql parameter .
and truly why i should define a sql parameter . is it really necessary to define a sql paramater then just define the type and set it to img and do all of that things ?
|
|
|
|
|
mohammadkaab wrote: is it really necessary to define a sql paramater
Yes. Concatenating the value into the SQL-string is insecure. Hence, all queries with parameters.
Why is it a problem? Don't tell me that it's "too much typing".
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
No , absolutly not , when i want to insert some data to the database the only thing i do is to use command text and then do the rest . but i though , inserting img into the database is also like inserting string.
ty anyway.
|
|
|
|
|
Any variable inserted should be using a parameter. Also strings.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
con.open();
com.connection = con;
com.commandtext = @"insert into table1 (name,family,id)values('"+textbox1.text+"','"+textbox2.text+"','"+textbox3.text+"')";
com.executenonequery();
con.close();
im using this type of inserting without of sql parameter , so ? is it wrong ?
|
|
|
|
|
mohammadkaab wrote: im using this type of inserting without of sql parameter , so ? is it wrong ?
Yes/no. It's not "wrong" in the sense that it will not compile or run, but it is wrong in the sense of being secure. It's recommended to use parameters to prevent SQL-injection attacks. Concatenating strings is heavily frowned upon, the more there it gives one a headache with formatting dates in different parts of the world.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Try typing the following in textbox3 :
Robert');drop table table1;--
Your query now becomes:
insert into table1 (name,family,id)values('me','Corleone','Robert');drop table table1;
That's two queries - one to insert a record, and one to drop the table. The -- comments out the rest of the query.
Congratulations - you've just met little Bobby Tables[^].
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Yes, it is wrong. Very wrong: anyone with access to the page that submits those text boxes, and an educated guess at the type of query they'll be used in, can now execute arbitrary queries against your database with all the permissions of your script (which, if you're allowing SQL injection, you probably haven't closed down properly either).
Using parameterised queries is most important when you accept free text from the user.
|
|
|
|
|
Seriously, as the other have said, doing this is an enormous security hole. You might as well give users direct access to your database.
Now at least three regular members of the site have told you this, hopefully you'll get an idea of how bad it is to do this.
“Education is not the piling on of learning, information, data, facts, skills, or abilities - that's training or instruction - but is rather making visible what is hidden as a seed” “One of the greatest problems of our time is that many are schooled but few are educated”
Sir Thomas More (1478 – 1535)
|
|
|
|
|
Maybe the OP can tell us what his eventual web site address will be so we can all avoid it?
... and no offense to the OP but there should be some sort of test or something before people are allowed to write code that goes out on the net. What if he is writing a web site for kids and putting together the data access layer like this? I shudder to think about the black hats that would be licking their chops to get at the data with something so trivial as the sql injection attack he is inviting with his code.
|
|
|
|
|
for me the best mode is to use a parameter.
However, you can try to convert image to byte[] and then in string
var str = System.Text.Encoding.Default.GetString(byteArray);
but I'm not sure that it works 
|
|
|
|
|
How do i change user properties.
public string SetAttributesValue()
{
try
{
RunspaceConfiguration rsConfig = RunspaceConfiguration.Create();
PSSnapInException snapInException = null;
PSSnapInInfo info = rsConfig.AddPSSnapIn("Microsoft.Exchange.Management.PowerShell.Admin", out snapInException);
Runspace myRunSpace = RunspaceFactory.CreateRunspace(rsConfig);
myRunSpace.Open();
Pipeline pipeLine = myRunSpace.CreatePipeline();
Command myCommand = new Command("Get-user");
myCommand.Parameters.Add("Identity", sUserName);
pipeLine.Commands.Add(myCommand);
Collection<psobject> commandResults = pipeLine.Invoke();
foreach (PSObject cmdlet in commandResults)
{
}
return commandResults.ToString();
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
return null;
}
|
|
|
|
|
hey, i m working on a project , i am developing it in visual studio 2010, c# winforms and devexpress (also trying to change it to WPF MVVM)
its a kind of toolbox, toolbox should be generic i.e. if any new tool added, toolbox should automatically add it (when in network), toolbox and tool both should be auto update (i am using clickonce for this), i am using process.start to run a tool from toolbox (bcz toolbox and tools are loosely coupled), but now the new requirement is, that dlls which are using by different tools should reside with toolbox only and tool should have their reference only (i find it very difficult bcz toolbox is loosely coupled with tool) so if you can suggest anything that can help me to keep all dll with one application (toolbox) and other are only using ref. of it (tools)..or in another solution, if we have tight coupling between toolbox and tools (one solution , multiple project) then how can we achieve this function (dll only at one place) also the autoupdate (because clickonce is not supporting multiple project deployment as far as i know)..any help on this is appreciated.
JP
SSE
|
|
|
|