|
Usually when you deploy the application, the app.config becomes xyz.exe.config where xyz.exe is the application executable name.
One more thing app.config should be in the same directory where the executable located.
|
|
|
|
|
I am attempting to write my first custom component which requires a custom collection.
So far I have:
using System;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.ComponentModel.Design;
using System.Drawing.Design;
namespace MultiColumnComboBox
{
public partial class MultiColumnComboBox : ComboBox
{
public MultiColumnComboBox()
{
InitializeComponent();
}
}
[Editor(typeof(ColumnCollectionEditor),UITypeEditor)]
public ColumnCollection Columns
{
get { return Columns; }
set { Columns = value; }
}
public class Column
{
#region private variables
private bool _autoColumnWidth = false;
#endregion
#region public properties
public bool AutoColumnWidth
{
get { return _autoColumnWidth; }
set { _autoColumnWidth = value; }
}
#endregion
}
public class ColumnCollection : CollectionBase
{
public Column this[int index]
{
get { return (Column)List[index]; }
}
public void Add(Column column)
{
List.Add(column);
}
public void Remove(Column column)
{
List.Remove(column);
}
}
public class ColumnCollectionEditor : CollectionEditor
{
public ColumnCollectionEditor(Type type)
: base(type)
{
}
protected override string GetDisplayText(object value)
{
Column item = new Column();
item = (Column)value;
return base.GetDisplayText(string.Format("{0}", item.AutoColumnWidth));
}
}
}
The compiler does not like the section:
[Editor(typeof(ColumnCollectionEditor),UITypeEditor)]
public ColumnCollection Columns
{
get { return Columns; }
set { Columns = value; }
}
it highlights the ColumnCollection reference, but I don't understand why. Can an experienced C# coder please point me in the right direction of where I am failing?
It's hard being a simpleton
|
|
|
|
|
kanchoette wrote: The compiler does not like the section
it highlights the ColumnCollection reference
What is the error you get at compilation?
|
|
|
|
|
I get
"Expected class, delegate, enum, interface, or struct" and the ColumnCollection reference is highlighted (red wiggly line)
|
|
|
|
|
It's been awhile since I last worked with editors but if I recall correctly, you should use typeuf on the second parameter also. And when using two types, the second parameter is used for the base class so perhaps something like:
[Editor(typeof(ColumnCollectionEditor), typeof(CollectionEditor))]
Does that help or change the error in anyway?
|
|
|
|
|
Unfortuantely I get the same error. Many thanks for trying to help me though - much appreciated.
I know it's going to end up being something really dumb. Just wish I knew just what .. Grrrr .....
|
|
|
|
|
One more observation. If I'm reading correctly, the custom editor class is a nested class inside the MultiColumnComboBox. If so, what if you try to move the editor class outside directly under the namespace (along with the column class) or use MultiColumnComboBox.ColumnCollectionEditor syntax.
|
|
|
|
|
Dear All,
I am developing small application using c# where it could only send and recieve single attachment with body text.
I am using System.Net.Mail namespace to send my msgs, I can send msg and attachments using the classes located in this namespace.
i find some references to use EAGetMail.dll to recieve msgs with attachment, sure i used EAGetMail.dll, but i can recieve my email with attachment with the extenstion of .eml where i specify for it, "based on reference".
now i dont want to open my msgs with other applications, i wd like to open it my c# application which i am developing.
Your cooperation is really appreciated.
Abdul Rahaman Hamidy
Senior Student Student in Computer Science
Kabul, Afghanistan
Software Developer
|
|
|
|
|
Ok, so what is your question?
|
|
|
|
|
[code]
EAGetMail.MailClient mClient=new EAGetMail.MailClient("TryIt");
EAGetMail.MailServer sClient=new MailServer("mail.domain.com","user name","password", ServerProtocol.Pop3);
mClient.Connect(sClient);
MailInfo[] mInfo=mClient.GetMailInfos();
int count=mInfo.Length;
for (int i=0; i<count;> {
MailInfo info=mInfo[i];
Mail m=mClient.GetMail(info);
m.SaveAs(String.Format("c:\\{0}.xal", i), true);
}
[/code]
if u just pay attention, i am saving all my emails with the extension of ".xal".
now i dont know how to open this file in my own c# app. like the one which MS OUTOOK opens.
Abdul Rahaman Hamidy
Senior Student Student in Computer Science
Kabul, Afghanistan
Software Developer
|
|
|
|
|
Abdul Rahman Hamidy wrote: now i dont know how to open this file in my own c# app. like the one which MS OUTOOK opens.
With code, I guess. File.ReadAllText will do it to get the text, although storing the files at the root of c is obviously retarded. I'd use a database.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Yeah i can read the text from the file, but how about attachments, i have to show name of attachments in my application may be in a label.
now the problem is how to understand that there is an attachment with the email.
regarding saving file, its temporary i am going to save to database using stream.
Abdul Rahaman Hamidy
Senior Student Student in Computer Science
Kabul, Afghanistan
Software Developer
|
|
|
|
|
Hello fellow developers,
I have written an application to find and replace just about anything. It even has a nice web interface and keeps everything stored in a SQL Server DB.
I have no problem finding what I am looking for, the issue comes when I replace a hard coded string inside of an EXE or DLL.
For simplicity sake I just grab the whole file as bytes, use Encoding to get me a string, and use a RegEx to Find / Replace what I am searching for. I then take the string with the values replaced and use Encoding to switch it back to bytes and overwrite the file.
This works fine on text, but DLLs and EXEs appear to have been corrupted. I get the following error when I try to execute the EXE or and executable that references a DLL I have replaced the strings inside of.
Here is a copy of the Exception, 'ConfigurationManagement.Controllers' is the DLL I changed:
System.BadImageFormatException was unhandled
Message: Could not load file or assembly 'ConfigurationManagement.Controllers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The module was expected to contain an assembly manifest.
I am assuming I am writing the file incorrectly and by adding new bytes to it, that there is some internal data inside the DLL or EXE that does not match its file size and locations anymore.
Does anyone know how to correctly edit the strings inside of a binary file?
Kind Regards,
Ryan
|
|
|
|
|
Hi,
A lot of data in an executable file is not absolute; it could be offsets, pointer tables, whatever.
So you should not try and replace a byte array by another byte array of different length.
You can pad a string with spaces or null characters to replace a larger string.
If you need to replace by a larger string you are in some trouble; you then have to find space
to put the new data and adapt some pointers...
|
|
|
|
|
Wow, looks like I am going to need the help of a File I/O expert. I have no idea how I would adapt the pointers.
Unfortunately, I have no control over the string size being replaced. I am basically writing this application because we have a lot of legacy applications ( I mean A LOT ) that need to have their connection strings, folder locations, web service names, etc changed... some we don't even have source code for some of them anymore as it was lost in TFS migration.
This doesn't seem to be a well documented developer issue. I've tried searching for the past week, but I don't seem to be entering the correct tags to pop a good search. If anyone has any good links to some articles to help out with this, I would be grateful.
Regards,
Ryan
|
|
|
|
|
Hi,
first of all you may want and have a look at the PE File Format[^]; that will show you an EXE is
not that simple.
second, if they are truly legacy, then you don't have to worry about signed assemblies, and other
.NET stuff.
I am not familiar with TFS, wikipedia tells me it exists to keep source code safe, not to throw
it away?
changing strings isn't a developer issue any more, since normal development includes both
keeping the sources handy (and not patching object or executable files), and putting
configuration stuff into some configuration repository (often a simple INI file, nowadays often
an XML file).
if you are looking for an automated solution for patching new and arbitrary string values, you are out of luck. On the other hand, if you are in control of the new strings, you can apply some tricks to make them shorter rather than longer, e.g.:
- choose short names for servers, folders, ...
- use "map network device" to replace most of a path by something really short
etc.
If that does not solve it, I am afraid you have a major task at hand and might want and consider a full rewrite using modern technology, and resulting in having source files again.
|
|
|
|
|
Yes, TFS is to store your code, but unfortunately, there were no developers on the team that migrated it from SVN.....( doh! ) so some code was lost.
Very true about changing connection strings not being a developer issue anymore, and I agree whole heartedly, unfortunately, some developers are not as skilled as others, especially in the past... some even thought that by hard coding them that they were more secure... it's amazing who could pass for a developer a few years ago...
The whole point of this project I am on is to fix our current environment to point to network aliases so when our Data Center blows up... we can simply point the alias to our Disaster Recovery center and we are back in business.
I should have mentioned I am a contract developer, I'm just trying to fix the web of chaos that is at my current site
Thank you for your feedback about PE File Format!
Ryan
|
|
|
|
|
You're welcome.
And good luck...
|
|
|
|
|
On top of what Luc said, you cannot replace strings inside signed assemblies. Doing so breaks the security "wrapper" and the CLR will no longer trust the assembly.
|
|
|
|
|
Ahh good point, I'm glad most of the past developers here didn't even know what a signed assembly was...
On the positive side, atleast I know what binarys need updating and can do investigation on re-compling them and hopefully updating them to use configuration files rather then hard coding connections strings in the assembly.
Thanks for the reminder!
Ryan
|
|
|
|
|
If it is a managed assembly, you can recompile it with .Net Reflector and change string or use reflix plugin.
|
|
|
|
|
Cool, thank you for the suggestion, I think that will go on the "Plan B".
Regards,
Ryan
|
|
|
|
|
Hello,
how is it possible, if i have a List<t> with a specified type of class to catch all exceptions of the classes that are inside the List?
I have a method "AddToList(T myClass)" which adds me the class into the list, so how can i can tell the class that all exceptions should be handled by a specific function/method? I doesn't want, that one class inside this List could break my application. Is there something like a event "OnException" or something which i can handle?
|
|
|
|
|
Not possible. You'd have to do a try catch whenever you call a method on the object. Why do you fear the objects in this list ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Well i have them all in a list, because i want to make it work like plugins. So, i doesn't want, that a plugin can crash my application! How can i solve that? Because, OK i make the try/catch things, but what if someone who writes an plugin doesn't do it and so crashes my application? Or how can i report a crash or something? That i can block the adding of this plugin.
|
|
|
|
|