|
I've written a program to interface between Peachtree accounting and my application. No problems, everything works fine, however I want to streamline things.
To support Peachtree 2007 and 2006 requires a different Interop assembly to be generated. No problems there either, here's the problem: In my app, there is only 3 lines of code difference between using the 2006 and 2007 interop assemblies.
The Import method for 2007 supports returning a list of Guid's that were imported which I want to keep, and the 2006 version doesn't.
Currently I'm looking at having to use preprocessor directives to conditionally compile for the different Import methods and changing the references in my project before building.
This isn't ideal, I'd like to do it in code dynamically instead so at runtime it can work with either version by using the appropriate interop assembly.
I'm a bit mystified as to how to accomplish this. If I generate two interops named differently, let's say Interop.PT2006.dll and Interop.PT2007.dll and reference them both in my app then I'll have two interops in the same namespace clashing on all the methods which are for the most part identical.
I could change the namespaces, but then I'd have to futz around in my code all over the place to call the appropriate namespaced method and it would be a mess.
I guess I need to dynamically reference the correct interop at run time and somehow dynamically call the 3 methods that are slightly different in the interop at run time.
I just need a general kick in the right direction for this.
Any suggestions appreciated.
|
|
|
|
|
I get an error at this line saying, "unknown user and password" I know I put the right username and password in the right string.
throw new Win32Exception( Marshal.GetLastWin32Error() );
}
ALso, I get an error by___ "c:windows\system32\cmd.exe". It gives me an error by the \. Not sure why? I got an unrecognized escape sequence.
Can someone please help?
|
|
|
|
|
cpltek wrote: I get an error at this line saying, "unknown user and password" I know I put the right username and password in the right string.
throw new Win32Exception( Marshal.GetLastWin32Error() );
We'll have to see the code you used.
cpltek wrote: ALso, I get an error by___ "c:windows\system32\cmd.exe". It gives me an error by the \. Not sure why? I got an unrecognized escape sequence.
If your doing this in C#, the path should look like:
string path = @"C:\Windows\system32\cmd.exe"
or
string path = "C:\\Windows\\system32\\cmd.exe"
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
here is the code ...
namespace ImpersonatorDemo
{
///
/// Main class for the demo application.
/// Call this application with a low privileg account to test.
///
class Program
{
///
/// The main entry point.
///
[STAThread]
static void Main( string[] args )
{
// Impersonate, automatically release the impersonation.
using ( new Impersonator( "administrator","", "password here" ) )
{
// The following code is executed under the impersonated user.
string[] files = Directory.GetFiles(@"\\misfs\public\DST Update\xpdstupdate.exe");
}
}
}
}
now it says..Could not find a part of the path '\\misfs\public\DST Update\xpdstupdate.exe'.
-- modified at 16:56 Friday 16th March, 2007
|
|
|
|
|
You're missing the domain specifier. It's not optional. If the Administrator account is on the local machine, you either have to give this parameter the machine name or you can pass a single period, ".", as the domain. You cannot leave it as String.Empty as your code does. Doing that is not the same as passing NULL to the function.
Next time, you might also want to say that you got the code from "such-and-such" article here on CodeProject. Impersonator is not part of the .NET Framework and surprised me when I saw your code.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
|
Hi,
I have created a windows service in .net 2.0
Ran the InstallUtil.exe and can now see the windows service in services window.
Now I have modified the code in windows service. Built it with success. Ran the instalUtil.exe but fails. Is it necessary to uninstal first and then instal again for each build?
Thanks
|
|
|
|
|
arkiboys wrote: Is it necessary to uninstal first and then instal again for each build?
Yes, but there is a property in the project to avoid this, called UnistallPerviousVersion or some thing like this.
|
|
|
|
|
Why when I place DefaultValueAtribute before property to set a specific value, the result with that value is not seen in the property panel.
e.g
[DefaultValueAttribute(23)]
public int MyProperty
{
get { return myVar; }
set { myVar = value; }
}
In that case i see "0" value in property panel.
What is wrong?
|
|
|
|
|
The DefaultValueAttribute specifies the value your property is set to when you select "Reset" in a PropertyGrid.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Doesn't the property window of VS Designer contains PropertyGrid?
How to do that the defalt value of a property was displayed in Property Window and its code was automaticaly generated?
|
|
|
|
|
You simply have to write
myVar = 23; in the constructor of your class so that the property has its default value initially.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Thanks, i know that this code will work out. But the case is that I'm writing a component and it has properties. Some of them have default values that can be changed at design time. It should work like in other standard components which place their default value in a special area at design time when they droped on th design area and/or their properties changed.
That is what i need.
The constructor is good, but the values will be strictly embedded in component in that way what i exactly don't want
Regards,
Aleksey
|
|
|
|
|
alexeychik2001 wrote: Some of them have default values that can be changed at design time.
To what control do you refer here?
alexeychik2001 wrote: The constructor is good, but the values will be strictly embedded in component in that way what i exactly don't want
You want a variable default value? That's not how it works...
The default value is used to decide whether to serialize the property and whether to show the property value in the grid itself as bold or not.
I don't think you can have instance default values (supported by VS and the property grid, anyway).
Share and enjoy.
Sean
|
|
|
|
|
Take any control, for instance Timer and its property Interval. If you take a look on its metadata you'll see
[DefaultValue(100)]
public int Interval { get; set; }
I don't want a varable defaul value. I want that this default value could be seen at design time and changed at property window. How to do it?
|
|
|
|
|
alexeychik2001 wrote: Take any control, for instance Timer and its property Interval. If you take a look on its metadata you'll see
[DefaultValue(100)]
public int Interval { get; set; }
I don't want a varable defaul value. I want that this default value could be seen at design time and changed at property window. How to do it?
You can't. The default value is, as you see, compiled in the code. There is only 1 default value that a Timer.Interval property can have, and it's set at compile time.
You can't change that at design time, and you can't change it at run-time.
You can create a new control inherited from Timer that has a different default value for Interval (I just tried it), but all instances of that control will only have the single default value.
namespace WindowsApplication1{
class MyTimer : System.Windows.Forms.Timer {
public MyTimer() {
base.Interval = 200;
}
[System.ComponentModel.DefaultValue(200)]
public new int Interval {
get { return base.Interval; }
set { base.Interval = value; }
}
}
}
All instances of this new control have a default value of 200 for Interval , but it requires the code in the constructor, and it's constant for all uses (design time or run-time).
Share and enjoy.
Sean
|
|
|
|
|
here are my listview codes.i wanna add file sizes next to the folder names.what should i have to add between this codes or somewhere else? any idea?
private void txtDirectory_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
if( e.KeyData == Keys.Enter )
{
if( System.IO.Directory.Exists( txtDirectory.Text ) == false )
{
MessageBox.Show( "Directory Does Not Exist", "Invalid Directory", MessageBoxButtons.OK, MessageBoxIcon.Information );
return;
}
tree.Load( txtDirectory.Text );
}
|
|
|
|
|
Take a look at the SubItems collection of the ListViewItem class.
|
|
|
|
|
Hi all,
I have some problem with binded ComboBox:
I have class GsmNumber:
class GsmNumber
{
private int? _CompanyID;
public int? CompanyID
{
get { return _CompanyID; }
set { _CompanyID = value; }
}
}
And Company class:
class Company
{
private int _CompanyID;
public int CompanyID
{
get { return _CompanyID; }
set { _CompanyID = value; }
}
private string _CompanyName;
public string CompanyName
{
get { return _CompanyName; }
set { _CompanyName = value; }
}
public static List<Company> GetCompanyList()
{
return new List<Company>();
}
}
And I have form with ComboBox ( _uiCompany ):
_uiCompany.DisplayMember = "CompanyName";
_uiCompany.ValueMember = "CompanyID";
_uiCompany.DataSource = Firma.GetCompanyList();
GsmNumber oNumber = new GsmNumber();
oNumber.CompanyID = 3;
_uiCompany.DataBindings.Add("SelectedValue", oNumber, "CompanyID");
So I have ComboBox with ArrayList datasource and binded SelectedValue property. It works good (in combobox selected item is Company object with CompanyID = 3), but when i change item in combobox oNumber.CompanyID not changing! Why?
P.S. Sorry for ma English
|
|
|
|
|
|
hi,
does anyone know how can I make
form not inside my app transparent?
|
|
|
|
|
That's not a good idea. You could crash the application if it's doing something to the window that isn't supported by Layered Windows.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
1 Text box, 1 Context menu.
Well, i didn't want the context menu, so i got rid of it, like this:
this.textBox.ContextMenu = new ContextMenu();
And now it is gone, and it works. But, and you can try this yourself, if you right click it, and then drag away from the text box, when you release the mouse button, the menu appears, and you can copy / paste / undo etc.
Crazy huh?
|
|
|
|
|
Good Morning,
i have a problem again!
i have a form with a DataGrid.
imagine a datagrid with three rows, ok!
the focus is on first row and i click on enter it goes to second when i click again until the third row. when it is last row the focus stay there. i'd like it return to first row when i click on enter again.
Thanks a lot!
|
|
|
|
|
how do i insert an icon in the taskbar at runtime?
|
|
|
|