Tuesday, 29 January 2008
|
| COM Callable Library Problem Brady Kelly 13:33:05 |
| | I've just created a COM Callable C# class library, registered with the Register for COM Interop option, just for testing. Then I'm using some VBA code to instantiate the object and call it's only method. When I run the code below, I get an "Object reference not set to an instance of an object." error, but my object isn't Nothing.
I suspect the interop to be the problem. Has anyone encountered anything like this before?
Set pdGen = New PdfGenerator.PdfGenerator <My C# class>
ret = pdGen.GeneratePdf(xmlPath, conn)
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 1 answer | Add comment |
|
| Question about ComRegisterFunctionAttribute... Gyorgy Bozoki 04:50:43 |
| | Hi all,
I seem to have a problem with ComRegisterFunctionAttribute attribute. Here is a bit of sample code:
// Start of sample -------------------- // -------------------- // Sample.cs // -------------------- using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using System.Windows.Forms;
namespace SampleLib { public static class Guids { public const string CLSID_TestGuid = "33DE01D3-DC04-4198-AE5D-58B1A36FC122"; }
[Guid ( Guids.CLSID_TestGuid ), ProgId ( "SampleLib.SampleClass" )] [ClassInterface ( ClassInterfaceType.AutoDual )] [ComVisible ( true )] public class SampleClass { public void SomeFunc () { MessageBox.Show ( "Something" ); } }
public static class Helper { [ComRegisterFunctionAttribute] public static void RegServer ( Type oType ) { MessageBox.Show ( "Register" ); }
[ComUnregisterFunctionAttribute] public static void UnregServer ( Type oType ) { MessageBox.Show ( "Unregister" ); } } }
// -------------------- // AssemblyInfo.cs // -------------------- using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security.Permissions;
[assembly: AssemblyTitle ( "SampleLib" )] [assembly: AssemblyDescription ( "" )] [assembly: AssemblyConfiguration ( "" )] [assembly: AssemblyCompany ( "" )] [assembly: AssemblyProduct ( "SampleLib" )] [assembly: AssemblyCopyright ( "Copyright C 2008" )] [assembly: AssemblyTrademark ( "" )] [assembly: AssemblyCulture ( "" )] [assembly: RegistryPermissionAttribute ( SecurityAction.RequestMinimum, ViewAndModify = "HKEY_LOCAL_MACHINE" )]
[assembly: ComVisible ( false )] [assembly: Guid ( "86077dae-29ae-4905-855b-798aaa7be210" )] [assembly: AssemblyVersion ( "1.0.0.0" )] [assembly: AssemblyFileVersion ( "1.0.0.0" )] // End of sample --------------------
The build output is a single DLL, SampleLib.dll.
It seems that the above code builds without any errors but when I try to register the resulting DLL using regasm.exe, the RegServer and/or UnregServer function is never called. According to the documentation, these functions can be public or private (or internal), but they must be static and take a single Type parameter to be called during registration for COM.
Is there anything I need to do to make this working? I'm using .Net 2.0 with SP1 and I have this same behavior on several computers. Any advice would be greatly appreciated.
Thanks, Gyorgy Bozoki
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 5 answers | Add comment |
Monday, 28 January 2008
|
| Funny DataGridView behaviour - Hours and hours Brady Kelly 23:56:20 |
| | From last night I was at work until 03H30 this morning, due to, among other things, what I find a strange quirk in an unbound DataGridView. When I use a class derived from DataGridViewRow, and add two or more of these rows to the grid, without populating their cells (still creating them), all my custom properties are set to null from the second row onwards. It doesn't matter whether I populate the cells of the first row or not, it always survives, but for every subsequent row, if I don't populate at least one cell, it gets sanitised. Even if the first row has no populated cells, populating one cell on a subsequent row ensures its survival.
I will illustrate. I have numbered only the lines that are relevant. The grid does not allow additions, so there are only two rows.
1. In the current state, firstRow.RowName = "Row A", and lastRow.RowName = "Row B".
2. If I comment out line 4, firstRow.RowName = "Row A", and lastRow.RowName = {null}.
3. It doesn't seem to matter at all whether lines 1 and 2 are commented out or not.
public class NamedRow: DataGridViewRow
{
public NamedRow() {}
public NamedRow(string rowName):this()
{
this.RowName = rowName;
}
public string RowName { get; set; }
}
private void GridBadForm_Load(object sender, EventArgs e)
{
dgvLayout.Columns.Add("Column 1", "Column 1");
dgvLayout.Columns.Add("Column 2", "Column 2");
NamedRow namedRowA = new NamedRow("Row A");
namedRowA.CreateCells(dgvLayout);
1 //namedRowA.Cells[0].Value = "A One";
2 //namedRowA.Cells[1].Value = "A Two";
NamedRow namedRowB = new NamedRow("Row B");
namedRowB.CreateCells(dgvLayout);
3 //namedRowB.Cells[0].Value = "B One";
4 namedRowB.Cells[1].Value = "B Two";
dgvLayout.Rows.Clear();
dgvLayout.Rows.Add(namedRowA);
dgvLayout.Rows.Add(namedRowB);
NamedRow firstRow = (NamedRow)dgvLayout.Rows[0];
NamedRow lastRow = (NamedRow)dgvLayout.Rows[1];
Debug.Print(firstRow.RowName);
Debug.Print(lastRow.RowName);
}
|
| | Add comment |
|
| loggin on console app exit chris Burgess 20:46:28 |
| | Is there a way to setup an 'exit' event for a console application so that I can write to a log before the app terminates?
Thanks!
Chris
=================================== This list is hosted by DevelopMentor® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 7 answers | Add comment |
|
| Very funny issue with ADODB interop Brady Kelly 16:08:22 |
| | In one method in my Document class, I have the declaration following declation. It gives me CS0234: The type or namespace name 'RecordSet' does not exist in the namespace 'ADODB'
ADODB.Recordset sqlRs = new ADODB.Recordset();
However, in another method in the same class, I have the following declaration that compiles OK. In the same class! My ADODB reference is working for many such declarations in the project.
ADODB.Recordset qryRs = new ADODB.Recordset();
WTF???
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 1 answer | Add comment |
|
| Can I get a SqlConnection from an ADO connection? Brady Kelly 13:52:09 |
| | To solve a problem of participating in a transaction, where COM code calls into .NET 2.0 code, I need the .NET code to participate in the transaction started by the COM code. A distributed transaction is not an option, and sp_bindsession is not working.
I would like, if possible, to receive an ADO connection object in my .NET class, somehow convert that to an ADO.NET connection object, and be done with minimal code changes. However, it is not a train smash if I have to use ADO in my .NET code for the data retrieval. This is my worst case, but only involves minor changes. I just don't like it.
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 2 answer | Add comment |
|
| Negative rowIndex problem for new DataGridViewRow Brady Kelly 01:37:50 |
| | I create and add a new row to an unbound DataGridView. Then, if I try and access an item in the Cells collection of the row, as in my commented out code, I get an index out of range exception, rowIndex. I'm not specifying a row index, so I assume it is inferring it from the row object, whose rowIndex property is -1. However, when I access the cell through a row in the grids Rows collection, I'm happy, as in my other code. Can anyone explain this behaviour?
The exception:
Specified argument was out of the range of valid values.
Parameter name: rowIndex
The code:
ExportLineRow newRow = new ExportLineRow(); // Derived from DataGridViewRows.
newRow.ExportLine = newLIne;
newRow.CreateCells(dgvLayout);
dgvLayout.Rows.Add(newRow);
int cx = 1;
foreach (Column o in newRow.ExportLine.RecordLayout.Columns.Values)
{
int rowIndex = dgvLayout.Rows.Count - 1;
dgvLayout.Rows[rowIndex].Cells[cx].Value = o.ColumnValue;
// TODO Find out why this doesn't work. Why is rowIndex -1?
//DataGridViewCell c = newRow.Cells[cx];
//newRow.Cells[cx].Value = o.ColumnValue; // Exception thrown here.
cx++;
}
My column indexing is clearly not the problem, as in the following breakdown, the first snippet works with the same column index that's used in the second snippet, which failes:
Works:
foreach (Column o in newRow.ExportLine.RecordLayout.Columns.Values)
{
int rowIndex = dgvLayout.Rows.Count - 1;
dgvLayout.Rows[rowIndex].Cells[cx].Value = o.ColumnValue;
cx++;
}
Doesn't work:
foreach (Column o in newRow.ExportLine.RecordLayout.Columns.Values)
{
DataGridViewCell c = newRow.Cells[cx];
newRow.Cells[cx].Value = o.ColumnValue;
cx++;
}
|
| | 3 answer | Add comment |
Sunday, 27 January 2008
|
| Negative rowIndex for new DataGridViewRow Brady Kelly 16:55:33 |
| | I create and add a new row to an unbound DataGridView. Then, if I try and access an item in the Cells collection of the row, as in my commented out code, I get an index out of range exception, rowIndex. I'm not specifying a row index, so I assume it is inferring it from the row object, whose rowIndex property is -1. However, when I access the cell through a row in the grids Rows collection, I'm happy, as in my other code. Can anyone explain this behaviour?
ExportLineRow newRow = new ExportLineRow(); // Derived from DataGridViewRow.
newRow.CreateCells(dgvLayout);
dgvLayout.Rows.Add(newRow);
int cx = 0;
foreach (Column o in newLIne.RecordLayout.Columns.Values)
{
int rowIndex = dgvLayout.Rows.Count - 1;
dgvLayout.Rows[rowIndex].Cells[cx].Value = o.ColumnValue;
//DataGridViewCell c = newRow.Cells[cx];
//newRow.Cells[cx].Value = o.ColumnValue;
cx++;
}
|
| | Add comment |
Friday, 25 January 2008
|
| Simulate button click to trigger postback Brady Kelly 13:01:42 |
| | I have tried many ways of forcing a page refresh from within Javascript, but my learned colleagues of implemented some sort of URL uniqueness scheme to prevent caching and I think this is messing me around. I have a Refresh button on the page for a manual refresh, so how do I go about triggering the server side Click event for that button?
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 6 answers | Add comment |
|
| Javascript CallBack Brady Kelly 01:40:13 |
| | I have a list screen that opens a detail screen for editing. I would like to signal the list screen to refresh itself when the detail screen closes. What are my options?
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 5 answers | Add comment |
|
| Where has my references folder gone Peter Suter 01:40:13 |
| | Hi In VS2005 references in my web solution have gotten messed up (seem to be a mix of file and project references), and my references folder has disappeared. Is the missing references folder a symptom of a damaged install, or some sort of feature. How do I fix the project references?
thanks ps
=================================== This list is hosted by DevelopMentor® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 1 answer | Add comment |
Wednesday, 23 January 2008
|
| Version Incrementation Steve Abaffy 22:53:00 |
| | I have looked all over but cannot find where to set the version number for builds. I would like for each build of the program to increment the build number, but after repeatedly rebuilding the application it still shows build 1.0.0. Where do you set this in VS2005?
Thanks
|
| | 3 answer | Add comment |
|
| Optimal Structure for Inserting and Deleting Brady Kelly 21:50:54 |
| | My questions yesterday about linked lists were related to my use of them as a structure that easily allows insertions and deletions while maintaining existing order. Is there something better I can use?
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 15 answers | Add comment |
|
| User Interface Process Bill Bassler 18:52:33 |
| | More and more I work on web applications (as opposed to websites) that require rather complex user process navigation control. To some degree, with careful planning, some level of navigational control can be achieved through WebForms Page controller model and the use of controls like the MultiView. However, this method generally comes at a cost; usually/mostly in ViewState size.
A few years ago, I implemented the MS UIP app block partially to the purpose of user nav control. The xml navigation maps provided very tight control over paths that user could take through the application. I don't want to say that the UIP didn't have it's issues but it did provide a good level of user process navigation control plus a lot of the good separation of concerns due to its MVC aspects.
Over the years I've keep track of the UIP and it kind of has gone away. Its functionality appears to have been replaced by various implementions: PageFlow WWF; but this seems like another MS side project; I also see that asp.net will soon have an MVC option but I've not found any good info on the out-of-the box controller architecture and if it will support sequential support user navigational control/routing similar to the UIP.
Question: Is WWF PageFlow a good option for the user process navigation control in a very high volume business web application? Will MVC support user process navigation in some form? Are there other options?
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | Add comment |
Tuesday, 22 January 2008
|
| Build configurations Dean Cleaver 23:07:47 |
| | Sorry - possibly not the right place, but I have a problem with a project not offering a new build configuration. I added a "Live" build configuration, and all but one application has picked it up - this one application when I select live in VS (2005) it changes to Debug instead... it has no Live in its build configuration options.
How do I force that to update?
Dino
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 1 answer | Add comment |
|
| Derive concrete type from generic type. Brady Kelly 19:27:09 |
| | Say I wanted a collection of Field objects, but with some extra functionality, say constraints on how fields can be added. I decided List<Field> is a good fit for most requirements, but want to derive a MyFieldList. To the best of my limited generics knowledge, I have to derive a MyFieldList<T> anyway, but all my refinements in the child class only refer to type Field, so the generic parameter is basically redundant. Is there any way around this?
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 12 answers | Add comment |
|
| Swap nodes in a linked list Brady Kelly 13:52:35 |
| | Sorry if this is very obvious, but it escapes me now at a time of impending review. I have a LinkedList<BandLine>, representing a report Band, where BandLine is one line of text in the band, e.g. one of two detail line types, or a header line.
I present my linked list using a DataGridView, and am trying to implement 'Move Up' and 'Move Down' commands for band lines, which involves swapping nodes in my linked list. Now getting the BandLine to move is easy, using ElementAt and an index provided by the grid, but to complete the swap with AddBefore, I need a LinkedListNode at a specific index. How can I get this? My code is as follows, and AddBefore is incomplete without the node I mention:
private void MoveBandUp()
BandLine lowerBand = currentBand.ElementAt<BandLine>(dgvBands.SelectedRows[0].Index);
BandLine upperBand = currentBand.ElementAt<BandLine>(dgvBands.SelectedRows[0].Index - 1);
currentBand.Remove(lowerBand);
currentBand.AddBefore(???, lowerBand)
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 8 answers | Add comment |
|
| How to separate an ASP.NET application Claude Petit 00:46:32 |
| | Hi, I want to know how I can divide code for different client setup. The problem is I have a big application and I need to make packages to respond to client neeeds. By exemple, a client might just need something (some functionalities in an ASP.NET page), and it doesn't require something else (some other functionalities in an ASP.NET page). This way, I could invoice them for only what they need. I just want a way on how to make that. Tanks.
Claude Petit
=================================== This list is hosted by DevelopMentor® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 4 answer | Add comment |
Monday, 21 January 2008
|
| Emailing Problem Steve Abaffy 17:02:29 |
| | When I try to send an email from my code in the Development running debug it works fine, but when I try to send the same email from the production version I get an error that says Cannot relay for "Email Address". This only occurs on my machine, the other machines in the shop will all send the email just fine from the production version of the code? We are using the Sever 2003 SMTP for email. Any insight would be appreciated.
Thanks
|
| | 2 answer | Add comment |
Sunday, 20 January 2008
|
| Expiration of your subscription to the DOTNET-CX list L-Soft list server at DevelopMentor 14:00:05 |
| | Sun, 20 Jan 2008 06:00:05
Your subscription to the DOTNET-CX list has expired and you have failed to confirm it in the 14 day delay that you had been granted. You have therefore been automatically removed from the list. You can re-subscribe to the list, if you want to, by sending the following command to LISTSERV@DISCUSS.DEVELOP.COM:
SUBscribe DOTNET-CX
|
| | Add comment |
|
| Re: Casting of objects in different namespaces Stephen Patten 05:26:00 |
| | Thanks Shawn!
The Address class is the same across both objects , but just in different namespaces. I was hoping for a simple one liner, but it's looking like I'll have to write a mapper.
Take Care! Stephen
-----Original Message----- From: Discussion of building .NET applications targeted for the Web [mailto OTNET-WEB@DISCUSS.DEVELOP.COM] On Behalf Of Shawn Wildermuth Sent: Saturday, January 19, 2008 3:52 PM To: DOTNET-WEB@DISCUSS.DEVELOP.COM Subject: Re: Casting of objects in differnt namespaces
There is unlikely to be an easy conversion unless the two Addresses are exactly the same. You'll likely need to create code to convert one to the other (and probably back). You won't be able to cast them since they are two different types...especially if they are un-related. For example, one Address might call Zipcode "ZIP" and another call it "PostalCode". You'll need to have code that can convert between the two and represent defaults for non-overlapping data (e.g. one has Country and the other one assumes the U.S.).
GL
Thanks,
Shawn Wildermuth http://adoguy.com http://wildermuthconsulting.com Microsoft MVP (C#), MCSD.NET, Author and Speaker
The Silverlight Tour is coming to a city near you!
-----Original Message----- From: Discussion of building .NET applications targeted for the Web [mailto OTNET-WEB@DISCUSS.DEVELOP.COM] On Behalf Of Stephen Patten Sent: Saturday, January 19, 2008 6:36 PM To: DOTNET-WEB@DISCUSS.DEVELOP.COM Subject: [DOTNET-WEB] Casting of objects in differnt namespaces
Hello,
Don't know if that was the right title to give this but here goes..
Background: I have pulled down 2 web references into a 2.0 c# project. The author of the endpoints has created three classes, let's call them Agency, Advertiser, and Address and exposed Agency in one web reference and Advertiser in the other. Both an Agency, and Advertiser have an Address, and this is where the crux of my dilemma.
How do I convert/cast an Agency.Address to an Advertiser.Address, or what terms should I be trying to research so that I may try to figure this out on my own?
Thank you for your time, -- Stephen
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 3 answer | Add comment |
|
| Casting of objects in differnt namespaces Stephen Patten 01:37:57 |
| | Hello,
Don't know if that was the right title to give this but here goes..
Background: I have pulled down 2 web references into a 2.0 c# project. The author of the endpoints has created three classes, let's call them Agency, Advertiser, and Address and exposed Agency in one web reference and Advertiser in the other. Both an Agency, and Advertiser have an Address, and this is where the crux of my dilemma.
How do I convert/cast an Agency.Address to an Advertiser.Address, or what terms should I be trying to research so that I may try to figure this out on my own?
Thank you for your time, -- Stephen
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 1 answer | Add comment |
Friday, 18 January 2008
|
| How to invoke one of your own pages Ryan Heath 22:16:43 |
| | Hi,
Does anyone know how to call your own page *within* a page request? In a server click event I want to render another page (of my own) into a string for further processing.
I am about to use WebClient and call my own page, but it really doesn't feel right, there has to be a better way...
// Ryan
=================================== This list is hosted by DevelopMentor® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 5 answers | Add comment |
|
| Select datagridview row when right clicked Brady Kelly 17:56:48 |
| | I would like to adjust some validations, e.g. Insert doesn't work when the first row is right clicked, or something like that, but at the moment I first have to select the first row and the right click it. Is there any way out of this?
|
| | Add comment |
|
| Delegate.BeginInvoke and EndInvoke. Amit Bhatnagar 00:06:23 |
| | I have made a service to timeout a method call by launching a delegate asynchronously via BeginInvoke. The documentation states, indirectly, that the call to BeginInvoke should be followed by a call to EndInvoke to prevent leaks. However, I am not sure if the call to EndInvoke is required should the delegate timeout because the call to EndInvoke will block the thread and wait for the delegate to complete. So I think what I have is OK, but can anyone confirm if the call to EndInvoke is required if it timesout?
See the following code:
--- IAsyncResult asyncResult = d.BeginInvoke(null, new object());
if (asyncResult.AsyncWaitHandle.WaitOne(7000, true)) { // Not timed out... d.EndInvoke(asyncResult); }
else { //Timed out ... EndInvoke required here? }
The information contained in this e-mail message is PRIVATE. It may contain confidential information and may be legally privileged. It is intended for the exclusive use of the addressee(s). If you are not the intended recipient, you are hereby notified that any dissemination, distribution or reproduction of this communication is strictly prohibited. If the intended recipient(s) cannot be reached or if a transmission problem has occurred, please notify the sender immediately by return e-mail and destroy all copies of this message. Thank you.
|
| | 16 answers | Add comment |
|