|
Nevermind the references in the project if u use DllImport to call the dll.
Try specifing the full path of the dll to see if the dll could be found.
Also try to put in the dll into the bin folder of the project. (If your config.dll resides in the system32 folder,the app that calls the dll should be run in the same folder...)
Learning without thought is labor lost; thought without learning is perilous. (Confucius)
|
|
|
|
|
I tried putting the new version in bin folder. no help.
I'll see whether its possible to include full path of the dll in dllImport
However the last part of ur reply is not clear. What do u mean by my app should reside in system32??
thanks again.
Kit
|
|
|
|
|
I have a class that interops with a booking tool, the class only returns system._ComObjects
I can do late binding cause I know what type is being returned.
public BindingList<NameElement> GetPassengers()
{
BindingList<NameElement> names = new BindingList<NameElement>();
ComClass _comClass = new ComClass();
comClass.RetrieveCurrent();
foreach (NameElement name in comClass.IObj_NameElements)
{
names.Add(name);
}
return names;
}
The problem is that when I try to use this list to bind it to a control by setting it's datasource to this list, the displaymember and valuemember can't be set because I get the error : 'Cannot bind to the new display member.
Parameter name: newDisplayMember'
Calling properties from the NameElement objects is no problem:
Console.WriteLine(names[0].LastName)
I have no clue why the data binding doesn't work ...
Any help is as appreciated.
modified on Wednesday, January 27, 2010 8:40 AM
|
|
|
|
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Data.Odbc;
using System.Data.Common;
using System.Data;
using System.IO;
namespace sample27
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show("values get inserted");
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = "";
textBox2.Text = "";
}
}
class v
{
public static void main(string[] args)
{
string name = null;
string pwd = null;
int i=0;
string connstr = "/*connection string*/"
SqlConnection conn = new SqlConnection(connstr);
conn.Open();
StreamReader sr = new StreamReader(@"e:\v.txt");
string query = "insert into samplereg(username,password) values(@username,@password)";
name= sr.ReadLine();
while (name != null)
{
i++;
SqlCommand cmd = new SqlCommand(query, conn);
cmd.Parameters.Add("@username", name); //error
cmd.Parameters.Add("@password", pwd );
cmd.ExecuteNonQuery();
name = sr.ReadLine();
conn.Close();
}
}
}
}
error:Add(string parametername,object value) has been depricated.use Addwithvalue(String parametername,object value)
pls reply me ......
|
|
|
|
|
Well, the first thing I would try is using the recommended method.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
The second thing I would recommend is reading the suggestions, specifically, about wrapping code blocks in PRE tags.
Cheers,
Vikram. (Got my troika of CCCs!)
|
|
|
|
|
Try using the LiquidNitrogen object.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Don't be so ridiculous.
This is NOT what the LiquidNitrogen class was designed for.
|
|
|
|
|
Well, I was originally going to recommend The InternallyAdjustableThrowoutPiston object, but it's not as widely used, not to mention that LiquidNitrogen object has the same properties because they share the same base class (SpanishInquisition , which nobody expected), and it consumes a lot less memory.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: LiquidNitrogen object has the same properties because they share the same base class (SpanishInquisition, which nobody expected), and it consumes a lot less memory.
I would never have expected that. I was going to recommend using the ILeftHandThread Interface with the StarboardMufflerBearing object, but your solution is clearly better.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
Hi All,
I want to retrieve SSL Certification status in my C# application.
Can anybody help me?
Thanking You,
Sunil G.
|
|
|
|
|
|
|
Hello anyone..,
How we can differentiate between an encrypted and none encrypted txt???
i need a method for that, to using in my project...,
Please help me.........,,,
An encryption methode is below:
using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;
using System.Configuration;
namespace SharpPcap.EnCryptDecrypt
{
public class CryptorEngine
{
public static string Encrypt(string toEncrypt, bool useHashing)
{
byte[] keyArray;
byte[] toEncryptArray = UTF8Encoding.UTF8.GetBytes(toEncrypt);
System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
string key = (string)settingsReader.GetValue("SecurityKey", typeof(String));
if (useHashing)
{
MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
hashmd5.Clear();
}
else
keyArray = UTF8Encoding.UTF8.GetBytes(key);
TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
tdes.Key = keyArray;
tdes.Mode = CipherMode.ECB;
tdes.Padding = PaddingMode.PKCS7;
ICryptoTransform cTransform = tdes.CreateEncryptor();
byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
tdes.Clear();
return Convert.ToBase64String(resultArray, 0, resultArray.Length);
}
}
}
Regards...
modified on Wednesday, January 27, 2010 6:56 AM
|
|
|
|
|
3bood.ghzawi wrote: How we can differentiate between an encrypted and none encrypted txt???
You can't, not without decrypting. It is possible to perform a preliminary check to see whether the decryption "string" is HEX (which encrypted strings are), but not all HEX strings are encrypted information. The only reliable way is to attempt to decrypt, even then it only checks for the decryption key.
Also this is worrying:
3bood.ghzawi wrote:
string key = (string)settingsReader.GetValue("SecurityKey", typeof(String));
The app config is by-and-large publicly available, and the key *MUST*
be kept secret for the cryptography to be worth anything.
CCC solved so far: 2 (including a Hard One!)
37!?!! - Randall, Clerks
|
|
|
|
|
Hi,
I've a service that push data from MSSQL db based on time frequency. Everything is fine, except while starting the system. At this time alone an error is coming "Operation not allowed when the object is closed."
I traced this error, this is because my service is start the prcoess before the SQL server is stared. I can handle this either delaying my service process to 2 or 5 mins or I can handle this exception in my catch block.
But I want to know any other way to handle this, like can I force my service once the SQL server is started or Is it possible to check a windows service (SQL Server) was started or not.
If any idea pls share with us.
Thanks & Regards,
Rishi
WinCrs
|
|
|
|
|
Hi,
there is a possibility to set on which services your service depends. Only if these services are running your service will start too. Since you are using C# guess you wrote an installer for your service, did you? During the install you can set the ServiceDependsOn-property.
Have a look here:
http://msdn.microsoft.com/en-us/library/system.serviceprocess.serviceinstaller.servicesdependedon.aspx[^]
All you have to do is to set this propery during installation to the name of the sql server service name (check by open the properties of the service).
Regards
Sebastian
|
|
|
|
|
You should change the service config/start state by setting the "SeviceDependedOn" value with an array of services that needs to be started before your service can start.
ServiceInstaller example:
[RunInstallerAttribute(true)]
public class ControllerInstaller : Installer
{
public ControllerInstaller()
{
processInstaller=new ServiceProcessInstaller();
serviceInstaller=new ServiceInstaller();
processInstaller.Account=ServiceAccount.LocalSystem;
serviceInstaller.StartType=ServiceStartMode.Automatic;
serviceInstaller.DisplayName = "ServiceDisplyName";
serviceInstaller.ServiceName = "ServiceName";
serviceInstaller.ServicesDependedOn = new string[] { "MSSQL$SQLEXPRESS" };
Installers.Add(serviceInstaller);
Installers.Add(processInstaller);
}
private ServiceInstaller serviceInstaller;
private ServiceProcessInstaller processInstaller;
}
Now your service depends on a service called MSSQL$SQLEXPRESS (service name not display name) and
the system tries to start this service before yours. If it can't start this service your service can't start too.
Here some code to do this execution time:
(You need the permissions to access these registry keys!)
string[] szArrayDependsOn = (string[])Registry.GetValue("HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Services\\[YourServiceName]", "DependOnService", null);
if ((szArrayDependsOn == null) || (szArrayDependsOn.Length != 1) ||
(szArrayDependsOn[0] == null) || (szArrayDependsOn[0].ToUpper() != "MSSQL$SQLEXPRESS")
{
Registry.SetValue("HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Services\\[YourServiceName]", "DependOnService", new string[] { "MSSQL$SQLEXPRESS" }, RegistryValueKind.MultiString);
}
Greetings
Covean
|
|
|
|
|
And also handle it in a catch.
|
|
|
|
|
|
Dear folks,
I have many folders to compare but I don't know how I can make a comparison between them without lacking for memory usage.
I explain :
I have two servers with around 10TB of data each. I use "xcopy" command (on Windows-DOS) for making the copy incrementaly.
The first server have datas changing everytime but the other is just for mirroring. Sometimes I need to check if every folders between the two servers are the same (just the folder). I used IEnumerable/List<>... to do the work but consume CPU usage or memory usage.
The structure of the folders are the same so what I need is to compare each structure only.
If anybody have an idea (with a sample code or just the algorithm or pseudo-code) I should appreciate it.
Many thanks to you all.
|
|
|
|
|
Hi,
so could you post what you have already? First thought of me was to use threads, this will speed up the execution (maybe).
Regards
Sebastian
|
|
|
|
|
Thanks for your prompt reply but i think i found another idea. That's getting the list of the first server and try to find it into the second server. If the folder exist, do not care, otherwise log the foldername.fullpath.
for example, suppose i have this :
S1 : c:\rootfolder_S1\folder1\folder2\folder3
S2 : c:\rootfolder_S2\folder1\folder2\folder3
beginning from c:\rootfolder
- get list of folders for one level i got : folder1
- used Path.GetFileNameWithoutExtension(dir) and got : folder1
- use the Path.Combine(S2, foldername) and got : c:\rootfolder_S2\folder1
It's ok and very nice algorithm. But my problem, now, is how can i use this if recursing folders in S1. Using Path.GetFileNameWithoutExtension(dir) will get only the last name of the folder and if combining with S2, will got error or something else.
What i'm going to try is check the size of S1 (rootfolder only), and then use the substring(index) before combining with S2, but how can i get the size or lenght of S1. S1 : c:\rootfolder -> should have 13 characters.
This is my sample code :
static void Main(string[] args)
{
CombinePaths(args[0], args[1]);
}
private static void CombinePaths(string p1, string p2)
{
string[] dirs = Directory.GetDirectories(p1);
foreach (string dir in dirs)
{
try
{
int index = dir.LastIndexOf("\\") + 1;
string foldername = dir.Substring(index);
string combination = Path.Combine(p2, foldername);
if (!Directory.Exists(combination))
{
Console.WriteLine(dir);
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
Console.WriteLine(Path.GetFileNameWithoutExtension(dir));
}
}
this is what i have for now. I'll reply back if found how to have the number of the character of the source string.
Maybe not yet very clear my code but think it is still a draft code.
See you later.
|
|
|
|
|
So finally here is my final code which is what i expect to have (no lack of memory usage nor cpu usage) :
static void Main(string[] args) {
CombinePaths(args[0], args[1]);
}
private static void CombinePaths(string S, string D) {
int indexRoot = S.Length + 1;
var stack = new Stack<string>();
stack.Push(S);
while (stack.Count > 0) {
string dir = stack.Pop();
try {
foreach (string sd in Directory.GetDirectories(dir)) {
stack.Push(sd);
string foldername = sd.Substring(indexRoot);
string combination = Path.Combine(D, foldername);
if (!Directory.Exists(combination))
{
Console.WriteLine(sd);
}
}
}
catch (UnauthorizedAccessException e)
{
Log.Add(e.Message);
}
}
}
The principle is this : the program iterate all directories inside the root folder, then parse the length to the subdirectories that it combine with the destination server, to finally check if the folder just listed from the source server exist in the destination server. (I think it some kind of "dir /s" in DOS Command). It is what i expect to have during 9 days but i still need help to optimize my apps.
As I've just count now, some of my root folder contains 2,000,000 - 3,000,000 folders inside. So I do not want to iterate all of this but i need to stop at level ten (10) or twenty (20), means i need to specify a deep level of iteration but i don't know how to make it by using this stack<> techniques.
Any suggestions are welcome. Thanks for all!
|
|
|
|
|
I am drawing a custom graph in c# openGL.
When I load the program the the Y axis lables draws (it is draw as txt) but everything else, the box representing the bars on the graph and the axis dont draw until you resize the window normally going from full screen down to a smaller window then the graph draws properly.
Does anyone have any ideas why this might be or have had a similar problem.
thanks.
|
|
|
|