|
You need to include the namespace of that class in your project (if it is under a different namespace).
For e.g.
using System;<br />
using System.input;<br />
using myNamespace;
OR
alternately you could just try
new myNamespace.myClass() .Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
Abhinav,
I tried referencing the namespace but the main problem is the User Control can not find the separate class file. Everything works right when I include the Enum in the same file but when I try to use it it gives me errors that it can not find the assembly or reference.
Thanks
Andy
|
|
|
|
|
I saw your code (pasted above).
See a note here[^].
"The partial modifier is not available on delegate or enumeration declarations."Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
modified on Wednesday, February 10, 2010 10:09 AM
|
|
|
|
|
I don't fully understand your query - but are you just missing a project reference? As in solution exporer, project, references -> add reference? Regards,
Rob Philpott.
|
|
|
|
|
Rob,
All of these files are in the same Project I have a UserControl and a class in a separate file but the UserControl can not find the class. I tried putting all of these in the same namespace and tried to use the namespace (using myNamespace.UserControl) without any luck. I'm sure it is a simple fix but I am new to C#. It's not as easy as including a C/C++ header file.
-Andy
|
|
|
|
|
So (for my clarity) - you have a single project file which consists of various source files. Your custom control comprises just another set of source files in this project? What do you mean 'in a seperate file'?
I'm afraid I'm completely lost, but if it is just a namespace issue, get Visual Studio to resolve the namespace by doing a context menu on the type where the error arises and doing 'resolve namespace' (or something like that).Regards,
Rob Philpott.
|
|
|
|
|
Rob,
Sorry for not being very clear....
In my project I have:
myUserControl.ascx
|->myUserControl.ascx.cs
myUserControlSupport.cs
myUserControlSupport.cs Contians Enum that I want to use in myUserControl but myUserControl does not see it and I am lost on how to reference it. I have the same namespace and a partial class defined but it still does not see it.
Thanks for the Help!
-Andy
|
|
|
|
|
And just to make things even more clear ( ).. You get a compilation error, so it is not a matter of the Intellisense not keeping up with you and your classes?
|
|
|
|
|
Yes that is correct, I was getting Errors when I tried to compile.
-Andy
|
|
|
|
|
Well, that should work. Dunno. The enum is publically visible? Regards,
Rob Philpott.
|
|
|
|
|
Got it... Looks like VS was not seeing the other code behind, not sure why not but everything seems to be working right now. Has anyone else had problems like this with VS?
Thanks again for your help everyone
-Andy
|
|
|
|
|
|
You will probably get a better response in the WPF forum. If Barbie is so popular, why do you have to buy her friends?
Eagles may soar, but weasels don't get sucked into jet engines.
If at first you don't succeed, destroy all evidence that you tried.
|
|
|
|
|
mmm, I see why you say that, however, it's all code behind stuff and loading the listbox itself is not really using WPF as such. V.
|
|
|
|
|
Since we're getting so intolerant lately (the question was clearly not 100% related to WPF) I'll just delete it. V.
|
|
|
|
|
|
I can reply the same thing to people voting me down: How to answer a question.[^]
It's not 100% correct to delete the message, but I did so in order to avoid discussion.
Apologies if it really is that wrong to do so.V.
|
|
|
|
|
How does this apply? The ones who marked you down were following the guidelines. You were not.
3. If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
4. If the question is inappropriate then click the 'vote to remove message' button I know the language. I've read a book. - _Madmatt
|
|
|
|
|
exactly, my question was certainly not poorly phrased, not inappropriate, no bad english. I certainly believed it belonged in the C# forum as it was IMO not 100% related to WPF and I was developing in C#.
There was no reason for voting me down, hence my reply to you.
Secondly, I apologized for removing the message, let's just stop the discussion and forget about it.V.
|
|
|
|
|
Fair point. There seems to be too much willingness for people to spend time quibbling about things being in the wrong place and filling the forums up with arguments rather than insightful help. Regards,
Rob Philpott.
|
|
|
|
|
You will probably get a better response in the COM forum.
It looks like the COM component (or the caller of the com component) is taking too long to respond. I don't know enough about COM to really held.Antoine de Saint-Exupery: Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
|
|
|
|
|
thanks for the reply I appreciate it (people started voting me down for what reason I don't know).
I did see the COM bit in the message, but it surprises me as I don't have any references to a COM object.
Makes me think that this error must be weird indeed.V.
|
|
|
|
|
You should only get this error when you run it through the Visual Studio debugger. Your release mode executable will not throw this error or message. Of course freezing up your main thread for over a minute may not be a good thing to do but I guess you can live with that if the user knows that it's to be expected.
See this blog entry[^] for more info on this.
Oh btw I think you posted this in the right forum. It's just that when you mentioned WPF some people got mislead (people try and answer everything here, even on topics they are not familiar with - it's a mad rush I guess to be the first one to answer. kinda keeps the forum response time fast, so it's all good I guess)
|
|
|
|
|
Thank you very much for your answer !
I'll definitely check it out.
Nishant Sivakumar wrote: Oh btw I think you posted this in the right forum.
Thanks. For a minute things where idd a little hectic, God knows why.V.
|
|
|
|
|
I am using below code to check printing status but it always returns 0. It would be great if you can help me . i think there is some problem in the way i am using GetPrinter method
[DllImport("winspool.Drv", EntryPoint = "OpenPrinterA", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
private static extern bool OpenPrinter([MarshalAs(UnmanagedType.LPStr)] string szPrinter, out IntPtr hPrinter, Int32 pDefault);
[DllImport("winspool.Drv", EntryPoint = "ClosePrinter", SetLastError = true, ExactSpelling = true,
CallingConvention = CallingConvention.StdCall)]
public static extern bool ClosePrinter(IntPtr printer);
[DllImport("winspool.Drv", EntryPoint = "GetPrinterDataA", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
public static extern uint GetPrinterData(
[In] IntPtr hPrinter,
[In, MarshalAs(UnmanagedType.LPWStr)] string pValueName,
[Out, Optional] uint pType,
[Out, Optional] IntPtr pData,
uint nSize,
[Out] uint pcbNeeded
);
[DllImport("winspool.Drv", EntryPoint = "GetPrinterA", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
public static extern bool GetPrinter(
IntPtr hPrinter,
int dwLevel ,
IntPtr pPrinter,
int dwBuf ,
out int dwNeeded
);
[StructLayout(LayoutKind.Sequ
ential)]
internal struct PRINTER_INFO
{
public IntPtr pServerName;
public IntPtr pPrinterName;
public IntPtr pShareName;
public IntPtr pPortName;
public IntPtr pDriverName;
public IntPtr pComment;
public IntPtr pLocation;
public IntPtr pDevMode;
public IntPtr pSepFile;
public IntPtr pPrintProcessor;
public IntPtr pDatatype;
public IntPtr pParameters;
public IntPtr pSecurityDescriptor;
public uint Attributes;
public uint Priority;
public uint DefaultPriority;
public uint StartTime;
public uint UntilTime;
public uint Status;
public uint cJobs;
public uint AveragePPM;
}
[Flags]
internal enum PrinterStatus : uint
{
RS_READY = 0x00000000,
PS_PAUSED = 0x00000001,
PS_ERROR = 0x00000002,
PS_PENDING_DELETION = 0x00000004,
PS_PAPER_JAM = 0x00000008,
PS_PAPER_OUT = 0x00000010,
PS_MANUAL_FEED = 0x00000020,
PS_PAPER_PROBLEM = 0x00000040,
PS_OFFLINE = 0x00000080,
PS_IO_ACTIVE = 0x00000100,
PS_BUSY = 0x00000200,
PS_PRINTING = 0x00000400,
PS_OUTPUT_BIN_FULL = 0x00000800,
PS_NOT_AVAILABLE = 0x00001000,
PS_WAITING = 0x00002000,
PS_PROCESSING = 0x00004000,
PS_INITIALIZING = 0x00008000,
PS_WARMING_UP = 0x00010000,
PS_TONER_LOW = 0x00020000,
PS_NO_TONER = 0x00040000,
PS_PAGE_PUNT = 0x00080000,
PS_USER_INTERVENTION = 0x00100000,
PS_OUT_OF_MEMORY = 0x00200000,
PS_DOOR_OPEN = 0x00400000,
PS_SERVER_UNKNOWN = 0x00800000,
PS_POWER_SAVE = 0x01000000
}
private PrinterStatus GetPrinterStatus(string printerName)
{
PrinterStatus status = PrinterStatus.PS_ERROR;
PRINTER_INFO printer_info = new PRINTER_INFO();
Int32 error = 0, written = 0;
IntPtr hPrn = new IntPtr(0);
bool success = false;
int needed = 0;
if (OpenPrinter(printerName, out hPrn, 0))
{
GetPrinter(hPrn, 2, IntPtr.Zero, 0, out needed);
IntPtr ptr = Marshal.AllocHGlobal(needed);
GetPrinter(hPrn, 2, ptr, needed, out needed);
printer_info = (PRINTER_INFO)Marshal.PtrToStructure(ptr, typeof(PRINTER_INFO));
Marshal.FreeHGlobal(ptr);
ClosePrinter(hPrn);
status = (PrinterStatus)printer_info.Status;
}
else
{
status = PrinterStatus.PS_ERROR;
error = Marshal.GetLastWin32Error();
}
return status;
}
it would to great if you guys can help me to find whats wrong
|
|
|
|
|