|
Frst, work out when you need it by, then work out a budget. Finally post your estimates here and give the rest of us a laugh.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
See the first 3 articles mentioned on this[^] page.
/ravi
|
|
|
|
|
|
PInvokeStackImbalance was detected
Message: A call to PInvoke function 'XPExplorerBar!XPExplorerBar.NativeMethods::LoadBitmap
' has unbalanced the stack. This is likely because the managed PInvoke signature does
not match the unmanaged target signature. Check that the calling convention and
parameters of the PInvoke signature match the target unmanaged signature.
|
|
|
|
|
What is XPExplorerBar? A 3rd party control? If so, have you checked with them?
only two letters away from being an asset
|
|
|
|
|
Member 2117727 wrote: XpExploreBar in csharp
what is that ??
|
|
|
|
|
Seems like the product was against an older version of Windows that uses a different signature for LoadBitmap . Imho, the best you can do is contact the vendor and give them your OS details.
/ravi
|
|
|
|
|
I am developing a ASP application and have created a custom grid that sorts and has paging. Now, I have found that LINQ is great for doing grid searches and other action on existing generic lists that are bound to that grid. The question I have is that because web pages are non presistance and my generic lists have to be recreated from either cache or a new query, how can I use LINQ for doing things in my business layer Manager classes (i.e. ProductsManager)? I just want to get some ideas for its use when developing my business layer.
Thanks,
Steve
|
|
|
|
|
Steve Holdorf wrote: can I use LINQ for doing things in my business layer
The same way you would use any other code. What is the problem you are having?
only two letters away from being an asset
|
|
|
|
|
See, I have used LINQ in the presentation layer for manupulating data when a sort, search, filtering is done. This makes sense because I am binding and rebinding to controls (Grids, ListBoxes, etc.) and the same data is being used. The generic list are non-persistant and in the business layer I use things like a static ProductManager class to call the ADO object, or cache, and return Product objects. Now, because my data in the business layer, Results from cache, new queries etc. are specific to the generic lists and query, how is LINQ useful there. I don't want someone to write me a book, I just want some ideas.
Thanks,
Steve
|
|
|
|
|
If you have used LINQ in one piece of code then I still don't see what the problem is in using it in another. If you are asking more of a theoretical or design/architecture question, then I can't answer how you can use in your business layer, I don't know what it is.
only two letters away from being an asset
|
|
|
|
|
i have created DLL in C which i am going to use in my C# code .
DLL file is TestLib.DLL
C# file is Test_Net.cs
-----------------TestLib.dll ------------------------------------
#include <stdio.h>
extern "C"
{
__declspec(dllexport) char* DisplayHelloFromDLL()
{
char* x="bach ke kaha jaoge";
return x;
}
}
-------------------End of file TestLib---------------------------------
-------------------------Test_Net.cs------------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Reflection;
namespace Test_Net
{
public partial class Form1 : Form
{
[DllImport("TestLib.dll")]
public static unsafe extern char* DisplayHelloFromDLL();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
unsafe
{
char* y = DisplayHelloFromDLL();
label2.Text = Convert.ToString(y);
}
}
}
}
-----------------------------EOF Test_Net-----------------------
While Debuging i am getting an error saying that cannot convert from char* to object .can anyone tell me how to solve this problem?please anyone can tell me how to convert char* to string or char* to char it will be very usefull .
Any help appreciated
Thanks in advance.
|
|
|
|
|
Have a look at the System.Runtime.InteropServices.Marshal class, it has several different PtrTostring methods.
Dave
|
|
|
|
|
|
As most of my programming experience is from FORTRAN times, I want to apologize for this perhaps trivial question.
I'm writing a Windows appplication with its own namespace (DD4e). In the main form (MSCMain) I create an public ArrayList (myList). This arraylist is populated by instances from a specific class (MStat).
I want a sub-form for entering new instances of class MStat and appending the new instances to myList.
My problem is that after generating a new instance of MStat in the click-event of the OK button in my sub-form, I cannot reference myList from there to append it to.
Searching the class view yields DD4e.MSCMain.myList as I had expected.
So my question is: what is wrong with my approach or what may I be missing?
As I mentioned at the beginning of my post, object-oriented programming with a cool IDE is quite new for me, so please don't assume too much knowledge on my side.
Regards
Dirk Bock
|
|
|
|
|
Your problem is that myList is a member of the class MSCMain so your sub-form needs a reference to MSCMain in order to access it. There are broadly two approaches, each with variations.
1) If you really only want to have one instance of myList you can make it static. (It would be best if the list were a private member of MSCMain with a public accessor property.) eg:
private static ArrayList myList = blaah blaah;
public static ArrayList MStatList
{
get { return myList; }
}
MSCMain.MStatList.Add(theNewMStat);
2) If you want to keep myList an instance member you need to pass your sub-form a reference either to myList or to the instance of MSCMain (which it can use to access the list). eg, in MSCMain somewhere:
SubForm subForm = new SubForm(myList);
and in SubForm:
private ArrayList list;
public SubForm(ArrayList aList)
{
list = aList;
}
list.Add(theNewMStat);
Phil
The opinions expressed in this post are not necessarily those of the author, especially if you find them impolite, inaccurate or inflammatory.
|
|
|
|
|
Both of the methods Phil posted will work fine. However, the 'recommended' (but slightly more complicated until you get used to it) way is to use delegates or delegates/events. If you search the articles on here you'll find plenty of beginner and advanced examples.
I'd suggest using a generic list here instead by the way
List<MStat> myList
Dave
|
|
|
|
|
I have a class say Categories . This class has a singleton property say Current . Here is how that property code looks like
public static Categories Current
{
get
{
if (_categories == null)
LoadCategories();
return _categories;
}
} LoadCategories() method opens a XML file and creates Categories instance for the data given there. I would like to use a separate XML file when this class is running on test mode. For that I wrote the below code
const string defaultCategoryFile = "MainFileName";
const string defaultTestFile = "TestFileName";
public static bool IsTesting = false;
private static void LoadCategories()
{
FileStream stream = null;
if (IsTesting)
stream = new FileStream(defaultTestFile, FileMode.Open);
else
stream = new FileStream(defaultCategoryFile, FileMode.Open);
.............
} In the test class, I will make the IsTesting flag as true to load the test file. Is this a good approach or any other better methods available for this scenario ?
|
|
|
|
|
N a v a n e e t h wrote: Is this a good approach or any other better methods available for this scenario ?
No. The test is invalid because the code you are testing is not the code you will be running in the live system. The class under test should never know if it is in a testing state or not. It should run the same way regardless of it being in a test or live.
You may want to have some way of determining which file is opened from outside the class. e.g. The name is in some config information. You may want to consider using mock objects to mock out the file access and provide your own (although it is probably still easier to provide a test file).
Also, you may find that you have a specific bug that requires something specific in the file. You need the ability to run the test against many different files.
|
|
|
|
|
Thanks Colin - Mock objects are new to me. I will take a look at that. BTW, are you using NMock[^] for mocking objects ?
|
|
|
|
|
I've been using RhinoMocks - But it is really a matter of personal or company preference. As far as I can see most are all pretty much of a muchness.
|
|
|
|
|
I have Report named TopCPU.rpt which has embedded queries.
I want to generate this Report in PDF format based on the Data available in the database Say "REPORTER" on SQL Server. I wrote a below code but while runing i am getting runtime error
An unhandled exception of type 'CrystalDecisions.CrystalReports.Engine.LogOnException' occurred in CrystalDecisions.ReportAppServer.DataSetConversion.dll
Additional information: Logon failed.
Details: IM002:[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
Error in File C:\DOCUME~1\Server1\LOCALS~1\Temp\topcpu {C68B19D5-D303-4666-8008-D8586708315E}.rpt:Unable to connect: incorrect log on parameters.
Here is the code which i wrote.
**********----------------------************************
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.ComponentModel;
using System.Data;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
namespace AgainRepGeneration
{
class Conn
{
private Database crDatabase;
private Tables crTables;
private Table crTable;
private TableLogOnInfo crTableLogOnInfo;
private ConnectionInfo crConnectionInfo = new ConnectionInfo();
private ReportDocument crReportDocument ;
//private string _reportFile;
ExportOptions crExportOptions;
DiskFileDestinationOptions crDiskFileDestinationOptions;
public void ReporterConnection()
{
String exportPath = "C:\\Exported\\";
if (!System.IO.Directory.Exists(exportPath))
{
System.IO.Directory.CreateDirectory(exportPath);
}
crConnectionInfo.ServerName = "SERVER1\\OPS_MR";
crConnectionInfo.DatabaseName = "Reporter";
crConnectionInfo.UserID = "sa";
crConnectionInfo.Password = "hello";
//Get the table information from the report
crDatabase = crReportDocument.Database;
crTables = crDatabase.Tables;
for (int i = 0; i < crTables.Count; i++)
{
crTable = crTables[i];
crTableLogOnInfo = crTable.LogOnInfo;
crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
crTable.ApplyLogOnInfo(crTableLogOnInfo);
}
crDiskFileDestinationOptions = new DiskFileDestinationOptions();
crDiskFileDestinationOptions.DiskFileName = exportPath;
//'Set the exporting information
crExportOptions = crReportDocument.ExportOptions;
crExportOptions.DestinationOptions = crDiskFileDestinationOptions;
crExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
crExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
//Export the report
crReportDocument.Export(); //Getting error here
}
public Conn(string FileName)
{
ReportDocument newDocument = new ReportDocument();
newDocument.Load(FileName);
crReportDocument = newDocument;
}
}
class Program
{
static void Main(string[] args)
{
Conn RepConnection = new Conn( "C:\\DOTNET_Report\\topcpu.rpt");
RepConnection.ReporterConnection();
}
}
}
***********-----------------------************************
Could any one tell me what mistake i am making.....
I am not C# developer........ have only experience of VC++.
Just jumped to this lanaguage 3 days back.....
modified on Friday, May 23, 2008 6:05 AM
|
|
|
|
|
Hi,
Can anyone explain to me why in the below code, the List that I added to the dictionary is being cleared by the line of code after it.
NOTE: This method is running in a seperate thread, and allAdaptersAndPorts is a volatile instance variable.
<br />
DSPortAdapter adapter = null;<br />
List<string> portsList = new List<string>();<br />
String portBuff = null;<br />
<br />
try<br />
{<br />
for (Enumeration adapterEnum = OneWireAccessProvider.enumerateAllAdapters();<br />
adapterEnum.hasMoreElements(); )<br />
{<br />
adapter = (DSPortAdapter)adapterEnum.nextElement();<br />
<br />
for (Enumeration portEnum = adapter.getPortNames();<br />
portEnum.hasMoreElements(); )<br />
{<br />
portBuff = (String)portEnum.nextElement();<br />
portsList.Add(portBuff);<br />
}<br />
<br />
this.allAdaptersAndPorts.Add(adapter.getAdapterName(), portsList);<br />
portsList.Clear();<br />
}<br />
}<br />
<br />
catch (OneWireException ex)<br />
{<br />
DebugHelper.LogError(ex, true);<br />
}<br />
</string></string>
Cheers,
|
|
|
|
|
MarkBrock wrote: Can anyone explain to me why in the below code, the List that I added to the dictionary is being cleared by the line of code after it.
MarkBrock wrote: portsList.Clear();
Because you are calling Clear on this list and Clear method clears the list.
I guess you thought that clearing portsList wouldn't clear the list in the dictionary but you have forgotten that List class is reference type so what's actually stored in portsList is reference to the list so when you clear the reference, it gets cleared in the dictionary too. To avoid this you can add a copy of the list to the dictionary.
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
Yup that did the trick thanks for your help.
I hadnt realised it was a reference being stored in the dictionary
Cheers,
|
|
|
|