|
I already showed you in the links at the bottom of my previous post.
|
|
|
|
|
Hello Sir/Mam
I'm trying connect sql server 2000 in windows service with other system on same network.
there are 4 system connected without any problem. But on other 4 system, it is giving error
on connection open while starting windows service. The error is: "the service on local computer started and then stopped some services stop automatically" etc. Same Connection string working in web service
without any error. But giving problem in Window Service. Is there any Configuration setting of that server or sql server 2000. Any help will be highly appreciated.........
|
|
|
|
|
You've asked this in at least one other forum. Please, just use one forum per question.
|
|
|
|
|
can you use connection pool size 1 to 5 etc in your connection string
|
|
|
|
|
In a C# 2010 application that I will be writing, I am trying to decide if I should use regular expression or use a parsing routine to get to the nodes of an xml file I will be working with.
The xml file I receive is not to update my database locally. My response will update the database on the remote site.
Basically I will be obtaining an xml file from a remote web service. When I look at all the results that this web service gives to me, I can uniquely identify patterns in the data that would be appropirate for regular expressions.
However there will be times when I obtain a list of key values that occurs 1 to 500 times. Thus i am wondering if this type of parsing is possible using regular expressions. If so, how would I do that type of parsing with regular expressions?
Also, can you tell me and/or point me to a reference that will tell me how to accomplish this task, using a built in xml parser or code that shows how to parse xml?
|
|
|
|
|
|
|
Hello everyone! I am a new in C# and was trying to access a class from another.
I have created the file Cliente.cs below:
class Cliente
{
public string nome;
public int codigo;
}
Afterwards I have created the file TestaCliente.cs with this code:
class TestaCliente
{
static void Main()
{
Cliente c1 = new Cliente();
c1.nome = "Rafael Consentino";
c1.codigo = 1;
Cliente c2 = new Cliente();
c2.nome = "Jonas Hirata";
c2.codigo = 2;
System.Console.WriteLine(c1.nome);
System.Console.WriteLine(c1.codigo);
System.Console.WriteLine(c2.nome);
System.Console.WriteLine(c2.codigo);
}
}
I have tried to compile the file TestaCliente.cs via command prompt with "csc TestaCliente.cs" and the following error message appears :
Microsoft (R) Visual C# 2010 Compiler version 4.0.30319.1
Copyright (C) Microsoft Corporation. All rights reserved.
TestaCliente.cs(6,4): error CS0246: The type or namespace name 'Cliente' could
not be found (are you missing a using directive or an assembly
reference?)
TestaCliente.cs(6,21): error CS0246: The type or namespace name 'Cliente' could
not be found (are you missing a using directive or an assembly
reference?)
TestaCliente.cs(10,4): error CS0246: The type or namespace name 'Cliente' could
not be found (are you missing a using directive or an assembly
reference?)
TestaCliente.cs(10,21): error CS0246: The type or namespace name 'Cliente' could
not be found (are you missing a using directive or an assembly
reference?)
Obs.:The files are in the same folder.
What am I doing wrong?
Thank you
modified 30-Aug-12 6:32am.
|
|
|
|
|
jamesfrj wrote: What am I doing wrong? This:
jamesfrj wrote: tried to compile .. via command prompt Why would you ever do that? It's just going to cause trouble.
But it's possible, of course. One option is to compile "*.cs" (ie all .cs files in the folder).
For more info, see: Working with the C# 2.0 Command Line Compiler[^]
|
|
|
|
|
|
Few Points:
1. Its better to have namespaces & separate class files.
So, Cliente.cs would contain
namespace TestNs
{
public class Cliente
{
public string nome;
public int codigo;
}
}
and TestaCliente.cs would contain
namespace TestNs
{
class TestaCliente
{
static void Main()
{
Cliente c1 = new Cliente();
c1.nome = "Rafael Consentino";
c1.codigo = 1;
Cliente c2 = new Cliente();
c2.nome = "Jonas Hirata";
c2.codigo = 2;
System.Console.WriteLine(c1.nome);
System.Console.WriteLine(c1.codigo);
System.Console.WriteLine(c2.nome);
System.Console.WriteLine(c2.codigo);
}
}
}
2. Compile them.
csc TestaCliente.cs // this gives error. Because the compiler is not able to identify the reference class file.
Fix for it. Include the other referred files also.
csc TestaCliente.cs Cliente.cs // You need to include as many classes as you refer.
This would create an .exe file.
3. Execute the generated .exe
TestaCliente.exe //this exe will be there in the same folder where you have your class files.
Result:
Rafael Consentino
1
Jonas Hirata
2
Hope I answered the question
|
|
|
|
|
You haven't actually answered the question that was asked. That question was really, why didn't the csc.exe compile the two class files together.
|
|
|
|
|
I have answered it. It was due to namespace. I have placed classes under a namespace and it works.
That's what I commented at last. 'Try this solution and the program should work'.
|
|
|
|
|
A couple of points. The practice of putting multiple classes in one file should be discouraged. It becomes harder and harder to keep separation in your classes if you can't even be bothered to separate your code - never recommend something that shouldn't be done in a professional environment; if you did it working for me, I would make you fix it.
Second, read the title of the thread - it's how to access a class in one file from another file. Not, what hack can I do to get round this.
So, you have not answered the question.
|
|
|
|
|
Few Points:
1. Its better to have namespaces & separate class files.
So, Cliente.cs would contain
namespace TestNs
{
public class Cliente
{
public string nome;
public int codigo;
}
}
and TestaCliente.cs would contain
namespace TestNs
{
class TestaCliente
{
static void Main()
{
Cliente c1 = new Cliente();
c1.nome = "Rafael Consentino";
c1.codigo = 1;
Cliente c2 = new Cliente();
c2.nome = "Jonas Hirata";
c2.codigo = 2;
System.Console.WriteLine(c1.nome);
System.Console.WriteLine(c1.codigo);
System.Console.WriteLine(c2.nome);
System.Console.WriteLine(c2.codigo);
}
}
}
2. Compile them.
csc TestaCliente.cs // this gives error. Because the compiler is not able to identify the reference class file.
Fix for it. Include the other referred files also.
csc TestaCliente.cs Cliente.cs // You need to include as many classes as you refer.
This would create an .exe file.
3. Execute the generated .exe
..\Microsoft Visual Studio 10.0\VC>TestaCliente.exe
Result:
Rafael Consentino
1
Jonas Hirata
2
Hope I answered the question
|
|
|
|
|
You have, but you should reply to the OP here, not me. He doesn't get notifications of replies to me (one minor point, I would remove the Microsoft Visual Studio reference from the path as that could just end up confusing him).
|
|
|
|
|
Thank you, pramodhegde88! It worked perfectly.
|
|
|
|
|
Better use Microsoft Visual Studio. If you don't want to purchase a full version, you can get the "Express" edition for free. Just use the "Build" menu.
|
|
|
|
|
You're right. That happened because I was following a tutorial that does not use Visual Studio.
Thank you
|
|
|
|
|
When you're compiling a C# application or library, you have to include all the files you want to be compiled into the assembly.
If you want both of these files in the same assembly:
csc *.cs /out:TestaCliente.exe
or
csc TestaCliente.cs Cliente.cs
If you want a separate .dll for the first class, you can first create that with
csc /t:library Cliente.cs
... and then reference it like
csc TestaCliente.cs /r:Cliente.dll
In general, though, it makes more sense to use an IDE to manage your files as a project. I recommend SharpDevelop.
Edit: An IDE will do exactly the same thing, but it will construct the command for you even when it gets very complex, chain builds together for multiple assemblies and so on.
|
|
|
|
|
|
In SQL Server Integration Services (2008) I have a created a task script using C# that converts Microsoft Project (2010) MPP files to an ASCII text CSV format. The problem I have encountered is that because some of the files still have their macros enabled, the process stops and presents a window asking whether to "Enable" or "Disable" the file's macros. Because multiple files are being automatically processed, I need to set in the C# code a default of disabling all macros.
Does anybody know how to do this?
I tried the following, but couldn't get it to work because it would not recognize the "AutomationSecurity" item under Application. It returns the message: 'System.Windows.Forms.Application' does not contain a definition for 'AutomationSecurity'.
Application.AutomationSecurity = Microsoft.Office.Core.MsoAutomationSecurity.msoAutomationSecurityForceDisable;
Here are the references being applied at the top of the class file.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using Microsoft.Office.Core;
using MSProject = Microsoft.Office.Interop.MSProject;
Thanks.
The science of business is the science of service, to this end it is better to do more than you promise than to promise more than you do.
modified 23-Aug-12 17:37pm.
|
|
|
|
|
Read the message. Application is being resolved to System.Windows.Forms.Application. I suspect you are trying to interact with an instance of some other application class you've instantiated through interop.
|
|
|
|
|
Once the C# class files were pulled over and fully applied in the SSIS Task Script, the popup box requesting to either Disable or Enable macros no longer appeared. There is no code in the Task Script for disabling the macros.
This is no longer an issue.
|
|
|
|
|
Hi I am new to active directory. I have an application in c# and want to use active directory login dialogbox in the application. I saw lots of code everywhere. Want to know how the login screen will popup. Is it automatic if you call code below?
DirectoryEntry userEntry = new DirectoryEntry(users.Path, LDAPUser, LDAPPassword);
ADUserDetail userInfo = ADUserDetail.GetUser(userEntry);
userlist.Add(userInfo);
}
directorySearch.Filter = "(&(objectClass=group)(SAMAccountName=" +fName + "*))";
SearchResultCollection results = directorySearch.FindAll();
Thanks in advance,
Sai
|
|
|
|