|
WHOA! figured it out
enough guessing and checking seemed to work, lol
inside the DLL: (C++)
EXPORT void MyFunc(LPTSTR pString)
{
strcpy(pString,"text");
}
inside the exe: (C#)
[DllImport("mydll.dll")]
public static extern void MyFunc( [MarshalAs(UnmanagedType.LPStr)] StringBuilder str);
StringBuilder temp = new StringBuilder(128);
What my problem was was, i was trying to use the string inside the c# project as a pointer to point to the stuff in the dll, but what i needed to do was pass a pointer to memory inside the exe to the dll and have it assign stuff there. No pointers in C# is kinda awkward for me as a (7+ years C++ coder)
anyway, im talking to myself, good night
|
|
|
|
|
Hey guys,
I'm so sorry because this is probably one of the most stupid questions I ever asked, but hey, I once was a VB programmer and now started C#, you should be happy hearing that
Now what's happening, I'm creating a databound control in C# which uses an Sql connection in order to fetch it's data. To establish the connection we need a connection string, and so I check for the existance of if. When the connectionstring property was not set, I want to throw an exception telling the user that the connectionstring was not set.
throw new SqlException("Connectionstring not set");
Now when compiling I get the warning
No overload for method 'SqlException' takes '1' arguments
I cannot find what's really meant here, and how to solve it... Any ideas?
I love it when a plan comes together
|
|
|
|
|
It means that the SqlException class provides no constructor that takes 1 argument, in your case the error message.
Taking a quick look at MSDN shows that the SqlException class provides no constructor at all, so you'll have to throw some other exception. Unless, someone knows a workaround.
www.troschuetz.de
|
|
|
|
|
Stefan Troschütz wrote:
Unless, someone knows a workaround
A workaround to a no-public-constructor object?!?!?
I guess you could instantiate through reflection if you were THAT desperate to have a SqlException.
|
|
|
|
|
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
|
|
|
|