|
Just to make it clear - Are you assuming that you have the name of the Enum, in our case MyEnum, that can be searched in the assembly. The problem still remains on getting the name of the enum in the DescriptionAttribute derived class so that I can use it to locate the assembly in which it is defined.
Thanks for the help...
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
I'm still assuming that you want to get the type of MyEnum. The second paragraph shows how you could retrieve the full name. If you already know the full name (including namespace - you may be able to find this out using Red Gate's .Net Reflector), then you can pass this to Assembly.GetType
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
But to get the type we should have the name (namespace.MyEnum), which I don't have. I want to make it available in the DescriptionAttribute derived class.
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
Exactly. If you open the file in .Net Reflector, then you can search for MyEnum and get the namespace from there. But why not just make Type of MyEnum available in the DescriptionAttribute derived class, instead of the name; that way you can save the time it takes to call Assembly.GetType. As long as you know how to create your own attribute which accepts a Type instantiation and has a Type property, and how to use Assembly.GetCustomAttributes, you have the Type
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Are you trying to write a generic attribute or one that only works with MyEnum ? If it's the former, I can't see any way around passing typeof(MyEnum) to the constructor of SomeEnumAttribute.
|
|
|
|
|
there is a way though:
SomeEnum[Description(typeof(MyEnum),"value")]
write a constructor in SomeEnum attribute derived class and lo and behold you have the MyEnum type in the attribute class.
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
Um, isn't that what I said in my previous post?
I can't see any way around passing typeof(MyEnum) to the constructor of SomeEnumAttribute.
|
|
|
|
|
Hi
I am unable to connect to oracle using c# , its giving me exception like "Connection not open" and sometimes TNS error , i have tried several methods which are as under
string oradb = "Data Source=(DESCRIPTION="
+ "(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=ORASRVR) (PORT=1521)))"
+ "(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=mariam)));"
+ "User Id=system;Password=mariam;";
OracleConnection conn = new OracleConnection(oradb);
conn.Open();
and
string strCon = "Driver={Microsoft ODBC for Oracle};SERVER = 10.17.18.62; Uid=system;Pwd=mariam;";
OdbcConnection odbc_Con = new OdbcConnection("Driver={Microsoft ODBC for Oracle};Server=DEDICATED; UID=system;PWD=mariam;");
odbc_Con.ConnectionString = "Driver={Microsoft ODBC for Oracle};Server=DEDICATED; UID=system;PWD=mariam;";
odbc_Con.Open();
and
string strCon = "Driver={Microsoft ODBC for Oracle};SERVER = 10.17.18.62; Uid=system;Pwd=mariam;";
OleDbConnection oracleConn = new OleDbConnection();
oracleConn.ConnectionString = "Provider=\"OraOLEDB.Oracle.1\";User ID=system;Password=mariam; Data Source=XE; Extended Properties=\"\"; Persist Security Info=False ";
oracleConn.Open();
help will be appreciated
regards,
|
|
|
|
|
Hi friends,
I want to get the path of the current executable using C#.
In VB.NET, we do it something like this:
Dim aPath As String = Application.ExecutablePath()
Was wondering how to do this using C#!
Help needed,
ShreeR
|
|
|
|
|
string aPath = Application.ExecutablePath;
maybe that's what you want
Life goes very fast. Tomorrow, today is already yesterday.
modified on Thursday, June 4, 2009 4:04 AM
|
|
|
|
|
There's no need for the brackets; ExecutablePath is a property, not a method
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
That's what happens when you try to think so early in the morning
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Hi Musefan,
This code throws an error.
Error 1 The name 'Applicaton' does not exist in the current context C:\Documents and Settings\ShreeR.Bhattacharjee.MICROSOF-A84B6D\Local Settings\Application Data\Temporary Projects\ConsoleApplication1\Program.cs 14 28 ConsoleApplication1<br />
Anything to overcome this?
|
|
|
|
|
So it's a console application, try this...
string aPath = Environment.GetCommandLineArgs()[0];
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Your spelling of Application is wrong
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
hi!
i want user can enter single cot(')in textbox.
i m using SQL yog but it display error as the insert query become
('dgfd dfg ddf_'','','',8) u can see here actually there are for paramerte but it shows error
|
|
|
|
|
Use Replace function from C# code.
Something like:
TextBox1.Text.Replace("'","''");
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
Note: That is the correct way to escape a string for some specific databases, like MS SQL Server and MS Access. For other databases you need to do it differently.
It's important to use the correct escaping method for the specific database, otherwise the code is still wide open for SQL injections.
If you use a parameterised query instead, there is no need for escaping.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
I agree with you.
I just didn't have enought time to explain more in my first reply of this question.
I appreciate your additional answer.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
Your application is wide open for SQL injection attacks.
Please instruct your users not to enter this in the text field:
','','',8);drop table Users;--
Alternatively, you can correct the code. Use parameterised queries instead of concatenating the data into the query.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
well the solution you should take, and not just to solve you issue but make it more secure, is to use parameters[^] with the sql queries
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Hello, here is what i want to do:
I Have created ListView. I have added Some items.
Now i want to have ToolTip on those items. Not on Control, but every item woud have diffrent tooltip.
Thank you in advance
|
|
|
|
|
If you set the ShowItemToolTips property of the ListView control, then you can add a ListViewItem with has the ToolTip property set
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Dear Friends,
I want to execute below java script from code behind of C# .NET
string url="/AssetItems"+"/frm"+assetitem+".aspx";
str="<script type=text/javascript language=javascript>";
str=str+"parent.frames[main3].location.href = "+url;
str=str+"</script>";
Page.RegisterClientScriptBlock("Message1",str);
it gives me java script error as "syntax error"
two frames named as top and main3. In top frame I have some search criteria in which I need to do some C# coding and as per result I want to display a page in main3 frame.
Your quick help would be highly appreciated
Thanks and Regards
Murtuza Patel
|
|
|
|
|
I had a BHO appliaction (in-process dll injected in IE) which was developed in Vs2005 c#.
I had made an msi setup with the help of Setup and Deployment Project.
This was the installer class I had added in my project which generates the required dll...
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using Microsoft.Win32;
using System.IO;
namespace BHOPDF
{
[RunInstaller(true)]
public partial class Installer1 : Installer
{
public Installer1()
{
InitializeComponent();
}
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
public override void Commit(System.Collections.IDictionary savedState)
{
base.Commit(savedState);
}
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
public override void Install(System.Collections.IDictionary stateSaver)
{
base.Install(stateSaver);
}
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
protected override void OnCommitting(System.Collections.IDictionary savedState)
{
string regasmPath = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory() + @"regasm.exe";
string componentPath = typeof(Installer1).Assembly.Location;
System.Diagnostics.Process.Start(regasmPath, "/codebase \"" + componentPath + "\"");
base.OnCommitting(savedState);
}
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
protected override void OnAfterInstall(System.Collections.IDictionary savedState)
{
base.OnAfterInstall(savedState);
}
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
protected override void OnBeforeUninstall(System.Collections.IDictionary savedState)
{ string regasmPath = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory() + @"regasm.exe";
string componentPath = typeof(Installer1).Assembly.Location;
System.Diagnostics.Process.Start(regasmPath, "/u \"" + componentPath + "\"");
base.OnBeforeUninstall(savedState);
}
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
public override void Uninstall(System.Collections.IDictionary savedState)
{
base.Uninstall(savedState);
}
}
}
The problem is after I uninstall my setup, and If I check the registry
"Software\Microsoft\Windows\CurrentVersion\Explorer\Browser Helper Objects"
my dll gets un-injected.
After uninstalling, and after sometime, If I check the registry again there my dll is visible as injected. How this is happened?
What was the mistake in the code, can anyone suggest something to solve this?
|
|
|
|