|
Yup, I guess that should be it... Throwing an ArgumentException in case of an SqlException solves the problem.
I love it when a plan comes together
|
|
|
|
|
nikneem2005 wrote:
I cannot find what's really meant here
Sorry to state the obvious, but what is really meant is what it really says. The "Method" you are calling is actually a constructor (similar in signiture to a method). As the error states, there is no constructor which takes one parameter (argument).
You can confirm this by opening object browser in VS, navigating to system.data.sqlclient.SqlException - it has NO public constructors at all. The most likely reason for this is that SqlException was not intended to be used by client code. A quick look with .NET reflector confirms there is a serialization constructor on this object only.
Now, to answer your question, create your own exception, inheriting from System.ApplicationException, and throw this instead. Something like "ConfigurationException" would be relevant in this case and could be reused anytime where the app is not configured correctly.
|
|
|
|
|
I have created windows control library and accessing it thru internet explorer.
when i try to read xml file over the web i get a security error.
What could be the reason ?
I have set an evidence and permssion set (FileIo , execution permission) for the dll that will be accessed over the web.
And this dll in turn used in html page using
<object id="digitalReview" height="500" width="275" classid="http://localhost/CtrlLib/ControlLibrary.dll#ControlLibrary.DigitalControl" name="ucl" viewastext="">
<param name="VirtualPath" value="" />
My problem is :
I have one function called getXmlData() in the dll, which reads xml file.
http://localhost/triqweb/config/config.xml. But when I try to access getXmlData function, IE throws up a security error ?? What permission should I need to set to access the xml file. Please help.
- Sreenath
|
|
|
|
|
Hi Gurus,
I have a doubt regarding using connection pooling in my Windows.net application. Our application has around 30+ simultaneous users connecting to the database(Oracle), but the application is running on individual machines using the that machine resource. Any connection requests are made to the Database from the individual systems.If I pool the connection, is there any performance advantage?
Thanks in advance
Sapna
|
|
|
|
|
Definitely it has..
Try to use a singleton class for the connection.
I am not sure in oracle, but you can set maxpool and minpool size in connection string
--- boarders may have better idea.
Sreenath
|
|
|
|
|
How can I capture a video stream using C# and DirectX. Is there any other option available apart from directX.
And after capturing the video, I want to separate the frames of the captured video. Can someone guide me.
|
|
|
|
|
i had one class derived from ServicedComponent,let say ClassA, to return registry key values reside at the server machine. ClassA compile as dll and place in server machine, regsvcs and gacutil done in server.
then i got one client app project, which add reference to the ClassA.dll and call the ClassA's method to get the settings value. But the settings value that i get is not from the server (let say my client also got same settings key which value is different from server).
my question is why the ClassA object that created, although is transparent_proxy, is not at the server side process instead it is client side process? and how to make the ClassA as a server process object?
Thanks in advance
Mr. New
|
|
|
|
|
Hi friends,
I need validate the username and the password on the local machine. When I run my application a login screen pops up user enters the Username password. If these credentails are valid for the system I should the user to continue.
Can any one please help me
|
|
|
|
|
Disable Integrated windows authentication...
Disable Anonymous access .. these setting should be done for the virtual directory. In addition to the above modify authorization section in the web.config file have the following element
<deny users="?" />
Create WindowsPrincipal object by using Thread.CurrentPrincipal
From WindowsPrincipal get the WindowsIdentity object
WindowsIdentity have the IsAuthenticated method which say whether the user has authenticated (authentication done twice)
You will get several properties/ methods in windowsindentity object for accessing the user's credentials like username etc.,
|
|
|
|
|
Hi sreenath,
Thanks for the suggesstion
I need to get the password also authenticated as i need to provide it for one of the service which my application using. I have set the option "This accont" in the log on tab of the services.msc dialog. If I dont select this option and provide the currently logged in username and password service will not run properly.
Is there any other alternate option of setting the currently logged in username and the password to the service.
As I new can u please help me out.
|
|
|
|
|
The service is runs independant of the user that's logged in. Of course, it too needs an account to run under, be it a user account created for the purpose or the System account. Your service CANNOT change the account it's running under without first being stopped, change the account information in the Service Control Manager, and then restart the service.
But, I suspect this is not what you want to do. Your service apparently has to pass credentials along to some other process to do work for the logged in user perhaps? Then your service will have to be rewritten to handle the notifications of a user logging on and off and be able to have another application send it a username and password to use.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello,
This is a tough question that's driving me nuts. I have a stored procedure that returns three tables, which I store in a DataSet . The records in one of the tables (table 1, also contains a JOIN ) contain foreing keys from the other two tables.
My UI (a dialog box) lets the user add, edit and remove records in the three tables. He can even add a record in the first table with the foreign keys of the recently added records in tables 2 and 3.
The PK for all three tables are autogenerated (identity), and in the DataSet they are negative values (so they don't collide with the real values in the database.)
My question is, how do I call DataAdapter.Update to save all the changes to the database? It's not that easy because:
* The records in table 1 may contain references to records in the other two tables, whose PK are negative values. The references in table 1 must be updated to the actual values given in the database.
* Table 1 contains a JOIN , but also the PK from the joined table (other that these three) so it shouldn't be a problem, if I can manually update without including that column.
* Different tables, different commands to update. The data adapter only lets me specify one update, insert, and delete command; and here it must be different for each table.
Is there a "simple" way to do it? or should I go through all the changes and do the updates manually? is it a lot of work?
Thanks in advance for any help,
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
I create a very simple helloworld webservice using vs.net (let us call it myservice.asmx).I browse to the correspnoding wsdl - http://localhost/Myservice/myservice.asmx?wsdl;and save the generated wsdl to disk after removing the service element.
Now i intend to use the wsdl for generating another service.So I use the vs.net command prompt.
wsdl /server http://localhost/Myservice/myservicewsdl.wsdl /l:CS /out:InheritedService.cs
This gives me the error
Error: Unable to import binding 'MyServiceSoap' from namespace 'http://tempuri.org/'.
- Unable to import operation 'HelloWorld'.
- Specified cast is not valid.
So I separate out the types into a separate schema
My schema(testWSDLInheritanceTypes.xsd)
========
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema xmlns:tns="http://jpnws0t1/SchemaWSDL" elementFormDefault="qualified" targetNamespace="http://jpnws0t1/SchemaWSDL" id="DataSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="HelloWorld">
<xs:complexType />
</xs:element>
<xs:element name="HelloWorldResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="1" name="HelloWorldResult" type="xs:int" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
And the wsdl
=========
<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:i1="http://jpnws0t1/SchemaWSDL"
xmlns:tns="http://jpnws0t1/SchemaValidatedService"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
targetNamespace="http://jpnws0t1/SchemaValidatedService"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<import namespace="http://jpnws0t1/SchemaWSDL" location="testWSDLInheritanceTypes.xsd" />
<types />
</definitions
On using wsdl.exe on this file,I do not get any errors but a very helpful warning:no classes were generated.
How do I proceed to generate code?
|
|
|
|
|
if I declare a variable in a try block
<br />
try<br />
{<br />
XmlDocument configDoc = new XmlDocument();<br />
configDoc.Load(@"..\..\katalog.config");<br />
}<br />
How could I access it later on in the finally block?
<br />
finally<br />
{<br />
<br />
XmlNodeList categories = configDoc.SelectNodes(<br />
"/configuration/categories/category");<br />
XmlNodeList disks = configDoc.SelectNodes(<br />
"/configuration/disk_numbers/disk");<br />
<br />
RepositoryItemComboBox ProgramCategoryComboBoxEditProperties = <br />
programCategoryComboBoxEdit.Properties;<br />
ProgramCategoryComboBoxEditProperties.TextEditStyle = <br />
DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;<br />
<br />
RepositoryItemComboBox DiskNumberComboBoxEditProperties = <br />
diskNumberComboBoxEdit.Properties;<br />
DiskNumberComboBoxEditProperties.TextEditStyle = <br />
DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;<br />
<br />
foreach(XmlNode SingleCategory in categories)<br />
{<br />
ProgramCategoryComboBoxEditProperties.Items.Add(SingleCategory.InnerText);<br />
}<br />
foreach(XmlNode SingleDisk in disks)<br />
{<br />
DiskNumberComboBoxEditProperties.Items.Add(SingleDisk.InnerText);<br />
} <br />
}<br />
|
|
|
|
|
You can't access a variable declared in one block from another block. Declare the variable outside of the try block but assign it inside the block:
SqlConnection conn = null;
try
{
conn = new SqlConnection(connectionString);
}
finally
{
if (conn != null) conn.Dispose();
} BTW, this is actually what the following declaration resolves to when the class implements IDisposable :
using (SqlConnection conn = new SqlConnection(connectionString))
{
}
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi folks,
I created a Custom DataGrid Column Style, inherited from DataGridColumnStyle. It works fine, but now I want it to appear in the DataGridColumnStyle Collection Editor, along with the DataGridTextBoxColum and DataGridBoolColumn, in order to use it directly in the disign of the DataGrid layout.
Somebody could tell me how to do this?
Thanks in advance,
Enrique.
|
|
|
|
|
For information like this you need to know how the collection editor works to know if you can even do what you want. Use ildasm.exe from the Framework SDK (installed by default with VS.NET or downloadable from http://msdn.microsoft.com/netframework[^]) to read the IL (Intermediate Language, like a high-level assembler) or a tool like .NET Reflector[^] to decompile the code.
Look at the DataGridTableStyle.GridColumnStyles property to find that there's no EditorAttribute , so look at the property type - GridColumnStylesCollection , to find that it references the editor type System.Windows.Forms.Design.DataGridColumnCollectionEditor, System.Design . If you look at that class from the System.Design assembly you'll see that it's internal and you can't access it. It also doesn't expose any functionality that you can use statically through reflection.
The next best option is to sub-class DataGridTableStyle and override the GridColumnStyles to return your own derivative of the GridColumnStylesCollection class, attributed with your own editor class that derives from the same class that the current collection extends: the CollectionEditor class, which is public and defined under the System.ComponentModel.Design namespace.
Override the CreateNewTypes() method like so:
public class MyGridColumnStylesCollectionEditor : CollectionEditor
{
protected override Type[] CreateNewTypes()
{
return new Type[]
{
typeof(DataGridTextBoxColumn),
typeof(DataGridBoolColumn),
typeof(MyDataGridCustomColumn)
};
}
} You can do this a couple of other ways like implementing ICustomTypeDescriptor but it would be quite a bit more difficult.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi, friends. I need to build a report with crystal reports with a set of pairs of cells, but I need to do it PROGRAMMING, because I don´t know the number of pairs before running the program (this is calculated each time at runtime). I must be able to draw a 2xn matrix (2 rows and n columns), so I’ve thought to draw 2 little squares and repeat the operation n times (going to the next line if the end of the first one is reached). I’ve been told that all of this is perfectly possible, by accessing to the object model of the report, but I don’t have any single idea about how do thiss!.
It’s very important, since is the only thing I have to do in order to finish my Project, and I have do show it in February.
Thank u everybody, because I know you’re going to give me a hand
|
|
|
|
|
Hi
I've been using gacutil to add assemblies via command line. how can I add assemblies using this from with in my program ?
|
|
|
|
|
thepersonof wrote:
how can I add assemblies using this from with in my program ?
So are you asking how you can invoke gacutil from within you application. If so, check out the Process.Start[^] method.
|
|
|
|
|
Is it enough to hold a delegate to an object method, in order to keep it being collected?
And what about reference to some general member?
Thanks,
Yaakov
|
|
|
|
|
What exactly are you asking? Do you need to store a reference to a delegate in order to remove it from a event later? If so, the answer is "no". So long as the delegate references the same method for the same instance of a class that is already added to an event (which is a MulticastDelegate ), you can "new" up another one like so:
textBox1.TextChanged += new EventHandler(textBox1_TextChanged);
textBox1.TextChanged -= new EventHandler(textBox1_TextChanged); A delegate is like a managed function pointer. So long as the function pointer (the method to which the delegate points) is the same - the same method on the same instance or a static method for a class - the delegate is the same.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi,
I want to create a simple application that opens a window form with controls (mainly text boxes) that feed from a DB. I'm using a DataSet to get the data from the DB but unlike in VB.NET i wasn't able to find the equivalent of:
Me.BindingContext(DataSet11, "tableName").Position
Therefor i am unable to "travel" between rows in the table easily.
The final application is designed to: display, add, delete and modify rows of different tables in the DB and also preforms some algorithms (Using VB.NET is'nt a good solution).
Thank you.
|
|
|
|
|
To navigate data you use a CurrencyManager . It just so happens that the documentation[^] for the CurrencyManager in the .NET Framework SDK has an example of exactly what you're asking.
You get a CurrencyManager for your BindingContext - and all controls to take advantage of navigation must be bound to the same BindingContext , so BindingContext(DataSet11, "tableName") is different from BindingContext(DataSet11.Tables["tableName"], null) - and change the Position .
Be mindful that your comment about this being available in VB.NET is unfounded. The whole point of the CLI (Common Language Infrastructure) - of which .NET is Microsoft's implementation - is to provide a consistent compiled codebase for which any managed language can use (namely assembly modules). This is the purpose of IL (Intermediate Language), to which all managed languages compile. VB.NET and C# compilers may write slightly different IL due to optimization and language features, but IL modules (in assemblies) can be used by either. There are a few rules regarding CLS compliancy, but for the most part everything is the same for most managed languages (JScript.NET is only CLS-compliant, so it doesn't support additional features like unsigned primatives).
So, the Control.BindingContext property is available to C#, VB.NET, Managed C++, Perl .NET, and many others because it's defined in an assembly. BTW, the BCL assemblies (Base Class Library) are primarily written in C# so the fact your using them in a VB.NET application is just further proof of the CLI.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi, friends. I need to build a report with crystal reports with a set of pairs of cells, but I need to do it PROGRAMMING, because I don´t know the number of pairs before running the program (this is calculated each time at runtime). I must be able to draw a 2xn matrix (2 rows and n columns), so I’ve thought to draw 2 little squares and repeat the operation n times (going to the next line if the end of the first one is reached). I’ve been told that all of this is perfectly possible, by accessing to the object model of the report, but I don’t have any single idea about how do thiss!.
It’s very important, since is the only thing I have to do in order to finish my Project, and I have do show it in February.
Thank u everybody, because I know you’re going to give me a hand
|
|
|
|