|
|
I don't think so. appDomains only come in during IPC, right? MY apps single threaded, and the exception gets stolen going between two methods of a single class.
|
|
|
|
|
dan neely wrote: which is a gui control event handler if it's relevant
Event handlers for GUI controls run on the UI thread, so any exceptions thrown from them will cause the message loop to terminate and Application.Run to return. How are you attempting to propagate the exception from the event handler?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
I didn't know that, and didn't do anything special. Is there a way to make it pass through? If not, I can change the structure of the app enough to avoid the problem.
|
|
|
|
|
I have the following enum:
[TypeConverter(typeof(E1C))]
public enum E1
{
a = 1,
b = 2,
c = 3
}
And the following converter:
public class E1C : EnumConverter
{
public E1C(): base(typeof(E1))
{
}
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
{
if(value != null)
{
if(destinationType == typeof(string))
{
if((E1)value == E1.a)
{
return "a a a";
}
else if((E1)value == E1.b)
{
return "b b b";
}
else if((E1)value == E1.c)
{
return "c c c";
}
}
if(destinationType == typeof(InstanceDescriptor))
{
FieldInfo fi = EnumType.GetField(value.ToString());
if(fi != null)
{
return new InstanceDescriptor(fi, null);
}
}
}
return base.ConvertTo (context, culture, value, destinationType);
}
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
{
if(value != null && value is string)
{
if((string) value == "a a a")
{
return E1.a;
}
else if((string) value == "b b b")
{
return E1.b;
}
else if((string) value == "c c c")
{
return E1.c;
}
}
return base.ConvertFrom (context, culture, value);
}
}
Now, on the property page every thing works fine, as well as in ASP .net page,
but within Windows Form, the designer generates the folowing code:
#region Windows Form Designer generated code
...
...
this.userControl11.E1 = WindowsApplication2.E1.b b b;
...
...
#endregion
As you can see, instead of generating:
this.userControl11.E1 = WindowsApplication2.E1.b;
It generated:
this.userControl11.E1 = WindowsApplication2.E1.b b b;
If anyone know this problem and its solution, it would be nice!
Thanks in advance!
Ilan
|
|
|
|
|
I posted this message in ASP.net by mistake.
However, minhpc_bk has answer this question, and it works fine!
Here is the link to the answer of the same question (if anybody is interested).
The answer
|
|
|
|
|
Hi All,
I got a big problem i have written some dlls in c# and they are working great in c# but i cant use them with c++(i can use the ones written in c++)
i am using
GetModuleFileName
and
GetProcAddress
commands GetProcAdress cant get the adress.
I know dlls are IL code so its compiler independent.
Thanks
|
|
|
|
|
Well if you mean "C++" as in "unmanaged C/C++" then you need to use some other mechanism like ActiveX because the two runtimes aren't the same (it is the same as expecting VB6 to use any C++ shared object as is). COM and ActiveX provide a language independent mechanism and hosting to bridge different runtime environments that would normally not be able to interact.
If you maen "C++" as in "managed C++ that runs on .Net" then it is all IL and you should be able to address the objects naitively in either language binding. Managed C++ obeys all of the same assembly loading rules as C# assemblies.
|
|
|
|
|
I am using .NET
I am using the code below i simplifed everything but it is not working
#include <windows.h>
#include <iostream>
#include <stdio.h>
#include <conio.h>
#define MAXMODULE 50
using namespace std;
typedef int (WINAPI*cfunc)();
cfunc tests;
int main() {
HINSTANCE hLib=LoadLibrary("basic.dll");
if(hLib==NULL) {
cout << "cant load dll" << endl;
getch();
return 0;
}
char mod[MAXMODULE];
GetModuleFileName((HMODULE)hLib, (LPTSTR)mod, MAXMODULE);
cout << "dell loaded" << mod << endl;
tests=(cfunc)GetProcAddress((HMODULE)hLib, "test");
if(tests==NULL) {
cout << "cant load functions" << endl;
FreeLibrary((HMODULE)hLib);
getch();
return 0;
}
int x = tests();
cout<
|
|
|
|
|
That won't work for managed dlls. Either use them as COM objects, or use Managed C++ to interface to them.
Absolute faith corrupts as absolutely as absolute power
Eric Hoffer
All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke
|
|
|
|
|
I need some help, bad. In trying to make a external macroing program. Were im stuck is at the part were you have the program automaticly send a key message to your program of choice. An example would be I hit the 'a' key and that tells the program to run a script. That uses keys and delay timers. All the code I have found is just about getting what key is pressed. I need the program to tell a nother program. Hay use this key then this key ect.
Thanks
|
|
|
|
|
it's possible to use hooks to send messages from one app to annother (search the forum for examples). IF you want to do something beyond what can be easily done by feeding the controlled app simulated user input you're dependent on the apps authors having provided some means to facilitate automation.
|
|
|
|
|
Thanks Dan, Ill see what i can dig up
|
|
|
|
|
I've posted this question before but i've not specified an important thing.
If i open a File in FileStream with FileAccess.Write, it is locked so i can't rightclick on it and copy or delete or move...
Is it possible in any way? ( I don't close the application or close the stream)
|
|
|
|
|
The operating system is being "nice" by honoring the file lock. What possible use case do you have to move a file that is still opened and being written too?
|
|
|
|
|
simply becouse it is a file that is created by my program and it is used just by my program.
When my program close the file is deleted.
I want to know if someone in some way can get that file durign my application running if my application is using it!!!
|
|
|
|
|
It is in the end just bits on a disk. If someone wanted to they could read it (unplug/cause a kernel memory dump, reboot and read the file). The file locking mechanim is strictly not a security feature: it is there to maintain a consistent IO for running applications. If you really want a file that is secured, then you must use security mechanism.
|
|
|
|
|
Hi!
I have already posted this question in this forum, but I have not yet got any response. So i have decided to post it again.
I am trying to create a RubberBand when cropping an image from a PictureBox using the mouse.
All is well when drawing the rectangle with the help of MouseDown, MouseMove and MouseUp events.
I don't know how to maintain aspect ratio of the rectangle when drawing it over the picture box (as in Adobe PhotoShop).
I can mail you my code for your reference.
Any Idea will be helpful.
-- modified at 12:12 Tuesday 25th October, 2005
|
|
|
|
|
I would think a simple approach to doing this would be to define a double aspect which you set to height/width of the original image (you'd need to put some checks in to avoid possible divide by zero exceptions here).
Then when tracking the rectange take whichever is largest of the (absolute) new width or new height and determine the value of the other variable (new height or new width) by multiplying/dividing this by aspect ...if that makes any sense?
If you think of a straight line being defined as y = mx + c, the gradient (m) of a line going through the bottom left and top right corners of the rectange should remain constant whatever the size of the rectangle.
Rob Philpott.
|
|
|
|
|
Memory Stream Problem :
I have a component class which access a local file and writes the contents of the file to a Memory using MemoryStream. This
is accomplished a method called "Initialize()". This method returns the MemoryStream object. This Class is shown below:
using System;
using System.IO;
using System.Net;
using System.Text;
namespace MemWriterComponent
{
public class MWC
{
//Private variables
private MemoryStream ms; //Used for writing to memory
private FileStream fs; //Used for reading local file
private string data; //string variable for holding data
public MWC()
{
//initialize private variables
ms = new MemoryStream();
}
//public method Initialize() which reads the local file and returns
//memory stream
public MemoryStream Initialize()
{
string fileName =
"D:\\NET_Prog_Samples\\Chapter2\\MemoryStreamExample\\MemWriterComponent\\bin\\Debug\\testy.txt";
//initialize the file stream object
try
{
fs = new FileStream(fileName,FileMode.Open,FileAccess.Read );
//read the contents of the file
byte[] bytesIn = new byte[fs.Length];
fs.Read(bytesIn,0,bytesIn.Length);
data = Encoding.ASCII.GetString(bytesIn);
//close fs
fs.Close();
fs= null;
//Write the read data into the memory
byte[] bytesOut = new byte[data.Length];
bytesOut = Encoding.ASCII.GetBytes(data);
ms.Write(bytesOut,0,bytesOut.Length);
return ms;
}
catch(Exception ex) {
Console.WriteLine(ex.ToString());
return new MemoryStream();
}
}
}
}
The second class (Console Application) tries to retrieve the contents from memory location. I made a reference to
MemWriterComponent, initialized the object and then tries to retrieves the contents from memory. This class is shown below:
using System;
using MemWriterComponent;
using System.Text;
using System.IO;
namespace MSReader
{
///
/// Summary description for Class1.
///
class MSR
{
[STAThread]
static void Main(string[] args)
{
try
{
//initialize the MWC component
MemWriterComponent.MWC mw = new MemWriterComponent.MWC();
MemoryStream msReader = mw.Initialize();
byte[] bytesIn = new byte[msReader.Length];
msReader.Read(bytesIn,0,Convert.ToInt32(msReader.Length));
string dataIn = Encoding.ASCII.GetString(bytesIn,0,bytesIn.Length).ToString();
Console.WriteLine(dataIn);
//clean up code
msReader.Close();
mw=null;
Console.ReadLine();
}
catch(Exception ex) { Console.WriteLine(ex.ToString());}
}
}
}
Problem is running a client doesn't give any error(s). But also doesn't print any thing.
If i try to retrieve Size of Memory Stream using Console.WriteLine( msReader.Length). the output is 611 bytes... which is
incidently the size of the file "testy.txt".
What am i doing wrong?
any suggestions???
|
|
|
|
|
farhan1976 wrote: Problem is running a client doesn't give any error(s). But also doesn't print any thing.
well you didnt write anything to print though it normal...
farhan1976 wrote: Problem is running a client doesn't give any error(s). But also doesn't print any thing.
If i try to retrieve Size of Memory Stream using Console.WriteLine( msReader.Length). the output is 611 bytes... which is
incidently the size of the file "testy.txt".
well it sure does or it would be a problem ^^
|
|
|
|
|
In the component Class, I did write data to the Memory stream - I opened Local File and read its contents -> string variable : data
//read the contents of the file
byte[] bytesIn = new byte[fs.Length];
fs.Read(bytesIn,0,bytesIn.Length);
data = Encoding.ASCII.GetString(bytesIn);
//close fs
fs.Close();
fs= null;
//Write the read data into the memory
byte[] bytesOut = new byte[data.Length];
bytesOut = Encoding.ASCII.GetBytes(data);
ms.Write(bytesOut,0,bytesOut.Length);
return ms;
|
|
|
|
|
my guess is that you need to do a ms.position=0; before returning ms.
|
|
|
|
|
hi
I need write a progam in .Net (c# or vb.net):
The program should display in a monitor(tv) video files(e.g. *.avi, *.mpg, ...) and also display TV channnels(analogical signal) depending on a schedule(user defined)
what I must use? ... ¿Managed DirectX?
Helpme please
|
|
|
|
|
hi
I need write a progam in .Net (c3 or vb.net):
The program should display in a monitor(tv) video files(e.g. *.avi, *.mpg, ...) and also display TV channnels(analogical signal) depending on a schedule(user defined)
what I must use? ... ¿Managed DirectX?
Helpme please
|
|
|
|