|
Hi Don,
some more ideas:
1.
if you have the source of the unmanaged code, you can add logging there too.
what I typically do is make it such that the unmanaged code logs to the managed world,
using a delegate (which becomes a function pointer).
2.
if the DLL has a simpler function somewhere, try that one first; or if you have the source,
add a simple function and try it (e.g. something that takes two ints and returns the product).
Success here proves you are accessing the DLL, and doing some P/Invoke correctly.
3.
I was a little surprised by the explicit NULL char in one of the args; if you try to get
a double NULL to the unmanaged world, I am not sure the marshaling will do that for you.
4.
if the unmanaged code throws an exception, it might just kill the thread without you noticing
(depending on which timer you use, you may get a separate thread).
You said "as if the function was not called", does the code return well from the unmanaged function, i.e. does the next (log) line get executed?
5.
If everything else fails my best guess is the unmanaged code executes but fails maybe
because there is no user, hence no "My Documents" and the like. Good error trapping should
catch that.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Luc,
Thanks for sparking an idea that did fix prt of the problem.
Your #5 comment did the trick (the "My Documents" bit!)
It appears that while it is running as a console app, any file calls are, unless otherwise directed, sent to the folder where the .exe file is.
In my case, to make this old .dll work, there MUST be a .cfg configuration file AND a file name reference .txt file in the same folder as the libhab2.dll.
As an console app, those were placed there by the installer.
I guess I assumed that this was the case with a Service also.
NOT.....!
All calls are sent to the C:\WINNT\System32 folder.
I placed copies of the .cfg and .txt (the .dll was alredy there) in there and it works!
Now I just have to figure how to redirect the "local" folder of a system login. (I guess I could leave the files in system32 but that feels wrong somehow!)
Error trapping did not help because the .dll just returned with a Zero and no other information. It had been writing to it's own log file, but I did not see it because I was expecting to to be created and added to in the C:\Program Files\OSNUCASReader folder, not C:\WINNT\System32.
If I had done a global search of my HD looking for "hafelog.log", I would have saved a week of hairpulling!
The log only had a line like this:
"20080116115428 23KDGWDLOG F_Dialog e 00085370Internal processing error encountered during routine operations. "
BUT, it would have let me know that the .dll was being called.
I just was not thinking about the System32 folder (too many trees to see the forest I guess)
Anyway, thanks for the suggestions and the spark to get me moving forward.
Don
|
|
|
|
|
Hi Don,
glad to be able to help.
yeah, I don't hesitate searching the whole C: drive for a file...; all too often something
gets stored in strange places.
Member 4372837 wrote: "20080116115428 23KDGWDLOG F_Dialog e 00085370Internal processing error encountered during routine operations. "
not the most useful message...
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Hi.
I am having some trouble with a tab control I am writing. I have a user control that contains a class derived from tabcontrol, and also a class that derives from tabpage. I also have a method that adds a tab:
public void AddTab()
{
PictureTab a_picTab = new PictureTab("Test Title");
this.TabPages.Add(a_picTab);
this.m_pictureTabList.Add(a_picTab);
this.Dock = DockStyle.Fill;
}
When called in the constructor this creates a tab correctly, however when called later on (from a gui requesting add tab) there is no tab added. I am sure this is a simple silly fault but if anyone has any suggestions they would be much appreciated.
Thanks
Dan
At university studying Software Engineering - if i say this line to girls i find they won't talk to me
Dan
|
|
|
|
|
DanB1983 wrote: there is no tab added.
Really? It's not in the TabPages collection or it is in the collection but it is not visible?
DanB1983 wrote: When called in the constructor this creates a tab correctly,
Perhaps there is something in the constructor, after it is called that is required?
And of course, have you read the documentation?
led mike
|
|
|
|
|
Oops sorry wasn't very clear there. It is in the tabpages collection but not visible.
The code for construction and add tab does the same:
public TabPictureBox()
{
AddTab();
}
public void AddTab()
{
PictureTab a_picTab = new PictureTab("Test Title");
this.TabPages.Add(a_picTab);
this.m_pictureTabList.Add(a_picTab);
this.Dock = DockStyle.Fill;
}
So when creating the object I add one tab, then when I wish to add another tab the collection is updated
but the tab is not visible. I have consulted the msdn documentation and added a tab according to that.
Thanks
Dan
At university studying Software Engineering - if i say this line to girls i find they won't talk to me
Dan
|
|
|
|
|
Well I just did this and it works so that makes me think the problem might be in your PictureTab
private void addTab()
{
string stext = string.Format("Tab {0}", tabControl1.TabPages.Count + 1);
TabPage newPage = new TabPage(stext);
tabControl1.TabPages.Add(newPage);
}
led mike
|
|
|
|
|
Hey, thanks for your help.
I think the problem may be higher up as that code snippet does the same for me as adding my custom tab. If you could have a look at the following code I would be grateful. I haven't worked much with creating user controls so am pretty sure it is a simple error some where.
Thanks
Dan
public partial class TabbedPanelPictureBox : UserControl
{
TabPictureBox m_tabPbx;
public TabbedPanelPictureBox()
{
m_tabPbx = new TabPictureBox(); //this will call TabPictureBox::AddTab()
this.BackColor = System.Drawing.SystemColors.AppWorkspace;
this.Controls.Add(m_tabPbx);
this.Dock = DockStyle.Fill;
}
private void TabbedPanelPictureBox_Load(object sender, EventArgs e)
{
}
public void AddTab()
{
m_tabPbx.AddTab(); //this will also call TabPictureBox::AddTab()
}
}
public class TabPictureBox : System.Windows.Forms.TabControl
{
private List<picturetab> m_pictureTabList = new List<picturetab>();
public TabPictureBox()
{
AddTab(); //Calls AddTab() and works
}
public void AddTab() //Doesnt appear to work outside of constructor
//even when just creating a normal TabPage
{
//PictureTab a_picTab = new PictureTab("Test Title");
TabPage a_picTab = new TabPage("Test Title");
this.TabPages.Add(a_picTab);
//this.m_pictureTabList.Add(a_picTab);
this.Dock = DockStyle.Fill;
}
}
At university studying Software Engineering - if i say this line to girls i find they won't talk to me
Dan
|
|
|
|
|
What version of .NET and Visual Studio are you using? I am on 2005 .NET 2.0 and the first line of code in a UserControl constructor is
InitializeComponent();
So I added your PictureTab class to my test app and the tabs add just fine in response to a toolstrip button click that I have on my form. I did comment out this.Dock = DockStyle.Fill; From the AddTab method as well as the constructor. It should not be in AddTab to begin with and I am not using the control in .Fill mode anyway.
led mike
|
|
|
|
|
Hey.
I am using VS2008 and .NET 3.5
Yeah I had missed InitializeComponent() so have added that but am still having no luck.
The control is in a dll and is referenced in my gui project then instantiated like this:
<code>private void C_GmaGui_Load(object sender, EventArgs e)
{
//Set the main panel to be from where it starts to the edges of the screen
/*SetControlSize(mainPanel, System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Right - mainPanel.Left,
System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Bottom - mainPanel.Top);*/
SetControlSize(panelMain, System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Right - panelMain.Left,
System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Bottom - panelMain.Top);
this.tabbedPanelPictureBox1 = new TabbedPanelPictureBox.TabbedPanelPictureBox();
SetControlSize(this.tabbedPanelPictureBox1,
System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Right - this.tabbedPanelPictureBox1.Left,
System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Bottom - this.tabbedPanelPictureBox1.Top);
//ClearOffScreenBitmap();
//DrawOffScreenBitmapToScreen();
}</code>
This creates the component fine and adds the first tab. However when this bit of code is called:
private void addTabToolStripMenuItem_Click(object sender, EventArgs e)
{
this.tabbedPanelPictureBox1.AddTab();
}
no tab is added. Just to be clear the code in the tabbedpanelpicturebox control is now:
public partial class TabbedPanelPictureBox : UserControl
{
TabPictureBox m_tabPbx;
public TabbedPanelPictureBox()
{
InitializeComponent();
m_tabPbx = new TabPictureBox();
this.BackColor = System.Drawing.SystemColors.AppWorkspace;
this.Controls.Add(m_tabPbx);
this.Dock = DockStyle.Fill;
}
private void TabbedPanelPictureBox_Load(object sender, EventArgs e)
{
}
public void AddTab()
{
m_tabPbx.AddTab();
}
}
and
public class TabPictureBox : System.Windows.Forms.TabControl
{
private List<PictureTab> m_pictureTabList = new List<PictureTab>();
public TabPictureBox()
{
AddTab();
}
public void AddTab()
{
//PictureTab a_picTab = new PictureTab("Test Title");
TabPage a_picTab = new TabPage("Test Title");
this.TabPages.Add(a_picTab);
//this.m_pictureTabList.Add(a_picTab);
//this.Dock = DockStyle.Fill;
}
}
I will try building it under VS2005 and .NET 2.0
Thanks
Dan
At university studying Software Engineering - if i say this line to girls i find they won't talk to me
Dan
|
|
|
|
|
Hi Guru's and Genii
I'm totally stuck here and now I'm clutching at straws.
What I want to do is use a WPF application in C# to place hooks on global low level system events and override some of them.
That's so NOT going to work... Why can't MS see that we need access to these things to expand the UI / UX of Windows?
Anyway, my last ditch attempt at a workaround, before throwing out my 3rd Yr Degree project was to 'cheat'.
I had the idea of a full screen and topmost transparent window. That would obviously allow mouse clicks, events, scrolling typing etc.. to happen to what ever windows / os is running.
However, I need to be able to have my 'invisible' application detect some of these events and perform different things to what the UI of Vista would normally do. I.e. have MY invisible app grab the event and not allow it to 'drop through'
Does anyone please have any ideas.. otherwise I think I'm going to fail my degree... arrgghhh!!!
Grrr.... WHY CAN'T MS GIVE US MANAGED CODE ACCESS TO LOW LEVEL GLOBAL SYSTEM EVENTS??? i.e. HOW windows flick WORKS???
Meh.
|
|
|
|
|
I know nothing about your question but i have heard that you will get to view/change ms code with next .net version
dont know how true it is....but wish it is true.
|
|
|
|
|
Member 4294062 wrote: WHY CAN'T MS GIVE US MANAGED CODE ACCESS TO LOW LEVEL GLOBAL SYSTEM EVENTS?
You can. Google around.
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
This[^] was posted earlier today - it's VERY cool!
|
|
|
|
|
Hi
my company mostly usesd 2.0 framework and i need to do certification for better career .
I know 3.0 would be the in thing in a while in my firm.
But I am in dilemma that should I go for 2.0 or wait for 3.0.
Please advise.
|
|
|
|
|
I been looking for a Socket Tool Kit thats free for C# Sharp on studio 2008
Some thing that will have doc's and help with. Creating Servers in a Windows Application.
|
|
|
|
|
|
Hi guys,
im using foreach to load some data from sqlserver and make appointmens from them in MS Outlook.
Something like this:
<br />
foreach (DataRow dr in dt.Rows)<br />
Bud the problem is that wen there are for example 2 rows in my DataTable, it most create 2 appointments, bud i see that the Seconde appointment always re-writes or removes the First one and then i see only 1 appointment in outlook.
Can somebody help me with this???
thanx
|
|
|
|
|
Can you provide a bit more code to what you are trying to do?
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
Hi Paul Conrad,
Thanx for your response. Here some code of how it is looking like :
Outlook.Application outlookApp = new Outlook.Application();<br />
Outlook.AppointmentItem oAppointment = (Outlook.AppointmentItem)outlookApp.CreateItem(Outlook.OlItemType.olAppointmentItem);<br />
<br />
<br />
SqlCommand start = new SqlCommand("SELECT Act_actualstart,Act_actualstarttime FROM Activities WHERE Act_imp_nr='" + nr + "'and Act_Hoofdactiviteit_index='" + hfdnr + "'and Act_nr='001'", myconn);<br />
SqlDataAdapter da_start = new SqlDataAdapter(start);<br />
DataTable dt_start = new DataTable();<br />
da_start.Fill(dt_start);<br />
<br />
foreach (DataRow drstart in dt_start.Rows)<br />
{<br />
subject = "Communicatie naar; " +nr +"; " + omschrijving ;<br />
outStart = new DateTime();<br />
outStart = Convert.ToDateTime(drstart[0].ToString());<br />
oAppointment.Start = outStart;<br />
<br />
outEnd = new DateTime();<br />
outEnd = Convert.ToDateTime(drstart[1].ToString());<br />
<br />
oAppointment.End = outEnd;<br />
oAppointment.Subject = subject;<br />
oAppointment.Body = body.ToString();<br />
oAppointment.Location = " ";<br />
<br />
oAppointment.ReminderSet = true;<br />
oAppointment.ReminderMinutesBeforeStart = 5;<br />
oAppointment.Importance = Outlook.OlImportance.olImportanceHigh;<br />
oAppointment.BusyStatus = Outlook.OlBusyStatus.olBusy;<br />
oAppointment.Save();<br />
}
|
|
|
|
|
Djavid j wrote: SqlCommand start = new SqlCommand("SELECT Act_actualstart,Act_actualstarttime FROM Activities WHERE Act_imp_nr='" + nr + "'and Act_Hoofdactiviteit_index='" + hfdnr + "'and Act_nr='001'", myconn);
Off topic, string concatenation for queries is very dangerous. Look up Colin Mackay' article on this site about SQL Injection Attacks and why parameterized queries are a good idea.
How many records is the dataset filling?
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
Hi,
There is one dataset. Bud i think that in this case the sqlcommand is not the problem, because i did a check:
everytimne that a appointment is made, i get a message: appointment made succfully.
And in this case i have to datarows, so i get two times the message, and e checked that ofter the first time i got the 'appointment made succesfully' i saw the first appointment in Outlook. bud wen i click on ok on the messagebox i get the second message:'appointment made succesfully', then i see in Outlook that the first appointment is gone, there is only the second one.
(sorry for my english )
|
|
|
|
|
Djavid j wrote: i have to datarows, so i get two times the message
It looks as if maybe your oAppointment.Save(); should be outside the foreach loop.
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
this way it diffenatly wil make just one appointment
|
|
|
|
|
Shouldn't
Outlook.AppointmentItem oAppointment = (Outlook.AppointmentItem)outlookApp.CreateItem(Outlook.OlItemType.olAppointmentItem);
be inside the foreach loop? That way the loop creates a new appointment and saves it instead of overwriting the same object and saving it each time.
|
|
|
|