|
Here is the factory method I use in a plug-in application I have. You do not appear to have a need for the "ICustomAttributeHandler" aspect of the logic so you should ignore that part.
public static object newInstanceFromCustomAttribute( Assembly assm, System.Type tAttribute, ICustomAttributeHandler handler)
{
object oret = null;
Module[] modules = assm.GetModules(false);
for(int nMod=0; null == oret && nMod<modules.Length; nMod++)
{
Type[] types = modules[nMod].GetTypes();
for(int nType=0; null == oret && nType<types.Length; nType++)
{
object[] attributes = types[nType].GetCustomAttributes(tAttribute, true);
for(int nAttr=0; null == oret && nAttr<attributes.Length; nAttr++)
{
if( handler.attributeQualifies( attributes[nAttr] as Attribute))
oret = assm.CreateInstance( types[nType].FullName);
}
}
}
return oret;
}
led mike
|
|
|
|
|
Hi mike,
i believe that i miss guided you. I dont want to find which types in an assembly have a custom attribute. I pretend to find which assembly has a specific custom Attribute.
So, want happens is I have an assembly that i know for sure that the custom attribute and i the only way that I get it saying that it has that attribute (return true) is comparing their FullName which,i think, is a rude solution to the problem.
Tanks for your help.
Best Regards
Pedro M.
|
|
|
|
|
hi
how to deploy my app with crystal report XI ? i am use VC# 2005.
and my another question is that how to access crystalreport objects (like text object) and change it's value ?
thanks.
|
|
|
|
|
Business Objects has several Windows Installer packages you can include with your installation. Be aware, however, they are huge.
The Crystal Reports XI Release 2 - .NET Merge Modules is around 150MB. Remember to set your Key in the MSM properties of whatever you use to build the installation package.
|
|
|
|
|
The environment is Visual Studio 2005 and my project was created via extensibility -> shared add-in.
How can I debug efficiently?
At present, I have to SETUP the add-in and start outlook manually each time I want to see the differences I have made to the program ...
|
|
|
|
|
Hi,
are there any roules for a dll written in C#, which can be called by a VBA Macro?
Private Declare Function foo Lib "foo.dll" (sfoo as string) as string
How does the C# code for such dll look like?
Ariadne
|
|
|
|
|
From C#, you would have to create a COM DLL to call from VB.
I do not think you can make native DLL's from c#, although you can in Visual C++.
|
|
|
|
|
How would I return the below in an array list object I started to stub it out but I confused myself. Any advice, help.
public void Execute() {
string strRoot = ConfigurationSettings.AppSettings["Root"];
DirectoryInfo dir = new DirectoryInfo(strRoot);
//Pass the Directory for displaying the contents
getDirsFiles(dir);
}
public void getDirsFiles(DirectoryInfo d)
{
//create my array of files using FileInfo object
FileInfo [] files;
//This will passed in or set to find zip files
//get all files for the current directory
string strFileType = ConfigurationSettings.AppSettings["FileType"];
files = d.GetFiles(strFileType);
//iterate through the directory and print the files
foreach (FileInfo file in files)
{
//get details of each file using file object
String fileName = file.FullName;
String fileSize = file.Length.ToString();
String fileExtension =file.Extension;
String fileCreated = file.LastWriteTime.ToString();
}
//get sub-folders for the current directory
DirectoryInfo [] dirs = d.GetDirectories("*.*");
foreach (DirectoryInfo dir in dirs)
if (dirs.Length > 0)
{
{
getDirsFiles(dir);
}
}
}
public ArrayList GetGrantFileInfo(NameValueCollection psRootDirs, string psFileType, string psIncludeFilter, string psExcludeFilter, ArrayList oFolder, CriteriaType oCriteriaType)
{
//Impliment GetGrantFileInfo()
// How do I take the code above and put it in here???? HELP.
ArrayList arrGrantInfo = new ArrayList();
GrantFileInfo oGrantFileInfo = new GrantFileInfo()
arrGrantInfo.Add(oGrantFileInfo);
return arrGrantInfo;
}
|
|
|
|
|
Hi all,
I am using a Microsoft Web Browser control in my C# application. I wish to disable right click context menu in it. Can anyone please tell me how do i achieve that.
I searched for a few article here, but they were not of much help.
Please help.
Thanks in advance.
*** Who said nothing is impossible? I have been doing it for a long time ***
|
|
|
|
|
this article[^] seems to solve it. Also, have you looked at the .NET 2's System.Windows.Forms.WebBrowser control?
|
|
|
|
|
Excellent.. just what i was looking for.
Thanks a ton!!
*** Who said nothing is impossible? I have been doing it for a long time ***
|
|
|
|
|
webBrowser1.IsWebBrowserContextMenuEnabled = false;
|
|
|
|
|
I'm trying to do the equivalent of this in LINQ:
StringBuilder q = new StringBuilder("SELECT * FROM customer WHERE city = 'New York'");
if (westCoast)
q.Append(" OR city = 'Los Angeles'");
Here's what I have so far:
var q = dc.Customer.Where(c => c.City == "New York");
if (westCoast)
q.Where(c => c.City == "Los Angeles");
But I end up with "WHERE city = 'New York' AND city = 'Los Angeles'";
How do I tell it to use OR instead?
Thanks,
Alvaro
God existing isn't entirely impossible, but there's absolutely no evidence for it, so... the personal God as described by the Christian Bible existing is just as likely as a Pink Unicorn having created the universe, oh.. say... last Thursday. It's equally possible the moon has a core made of cheese. It's equally possible this sentence is in Spanish when you're not looking. - Someone on the Internet
|
|
|
|
|
Hi Alvaro. I haven't used LINQ too much, but I understand the Where method takes a Predicate<Customer>. All you're doing is writing a lambda expression, kind of shorthand for an anonymous method. Here's a more verbose version that should work, assuming Where takes a predicate:
var q = dc.Customer.Where(Criteria);
...
bool Criteria(Customer input)
{
return input.City == "New York" || (westCoast && input.City == "Los Angeles");
}
I'm not sure, but you may be able to do this right inside the lambda:
var q = dc.Customer.Where(c => c.City == "New York" || (westCoast && c.City == "Los Angeles"));
|
|
|
|
|
Thanks for your reply Judah.
I was more looking to do this in two steps, as an exercise. The first step sets up the base query, and then it would start growing based on different criteria. As I discovered, the default behavior is to AND the conditions together on multiple calls to Where . I was hoping someone would know how do change that to use OR instead.
Regards,
Alvaro
God existing isn't entirely impossible, but there's absolutely no evidence for it, so... the personal God as described by the Christian Bible existing is just as likely as a Pink Unicorn having created the universe, oh.. say... last Thursday. It's equally possible the moon has a core made of cheese. It's equally possible this sentence is in Spanish when you're not looking. - Someone on the Internet
|
|
|
|
|
I'm afraid I don't know how to do in 2 seperate pieces rather than 1 query with multiple conditions. Have you tried asking in the MSDN forums? I'm thinking too few people here have played with LINQ, so it might be tough getting an answer.
|
|
|
|
|
Hello all,
I have a process that runs periodically and modifies data. At the end of the process, it needs to create an excel document and email it to several recipients. I've tested the excel generation code from a Winforms app and it works flawlessly. However, when I wrapped the same functionality in a Windows service, it just stops cold. No errors are thrown, and the service keeps running. Is it possible that Excel requires an interactive user to be automated (seems lame, but possible)? That's the only thing I can think of.
Will
|
|
|
|
|
There might be some user rights issues. Have you checked the event log? Are you logging the errors/exceptions, if yes, please check what that is. That could lead you to actual cause, why you are not able to work with excel.
- ashish
|
|
|
|
|
hi
i created a report in my solution with crystalreport for print my datagridview's records, and i add a date object to Crystalreport designer that show date in my report. but i want to change this vlaue in my app programmatically, but how to change it from my code ?
thanks .
|
|
|
|
|
Create a parameter field for the date. When you create the report object, use the ParameterFields Collection of the ReportDocument to find your paramter. Set it using the .CurrentValues.Add property of the ParameterField.
ReportDocument report = new ReportDocument();
report.Load(@"MyReportFile.rpt");
foreach(ParameterField field in report.ParameterFields) {
if(field.ParameterFieldName == "MyName") {
field.CurrentValues.Add(MyDateValue);
}
}
|
|
|
|
|
Does anyone know if it is possible to get a footer or a totals line in a Datagridview on a windows form? If anyone has any idea please help!!
|
|
|
|
|
there is no such facility provided by the data grid.you can do two things either make a custom control data grid or insert a new row in the table with desired values
sameer
|
|
|
|
|
I have an app that currently creates several worker threads in the mainform constructor. I'm currently modifying it to only allow one running copy at a time. The issue I have is that since the threads are created in the constructor prior to starting the app, when the already running check is done and the main thread isn't started they're orphaned and the 2nd instance remains hiding in the process list.
I've found two possible workarounds for this. The first is to move the thread creation from the form constructor to the OnLoad event, so that they're never created on the aborted 2nd instance attempt. The second is to explicitly create the form on the Main method and then do an explicit dispose, after the run call.
MyFormClass theForm = new MyFormClass();
SingleApplication.Run(theForm);
theForm.Dispose();
Is there any design reason to prefer one over the other?
http://www.codeproject.com/csharp/singleinstance.asp
|
|
|
|
|
why don't you do your test by using a mutex before Application.Run ?
|
|
|
|
|
The wrapper class I'm using to prevent multiple instances does do that. In order to remain a generic implementation that can just be dropped into additional apps however, it can't have any specific knowlege of what form it's creating. This means that the form has to be passed to the class that does the check and then launches the app, which in turn means that the constructor has to be called before making the check.
|
|
|
|