.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Melody Anderson
Post New Web Links

Interop problem: VB6 COM code functions incorrectly when called from .net code.

Posted By:      Posted Date: October 29, 2010    Points: 0   Category :.NET Framework

I have found recently with some machines or some user accounts that calling some VB6 code from .Net fails to execute properly.
I have two examples:

  1. I have this simple VB6 dll, called by VB.Net code, that calls another simple VB6 dll using createobject.  The second object displays a form modally with progress bars, runs queries against a SQL server database to create and fill a table, and then closes (unload) that progress form and returns the table name.  The first object then takes this data to do additional processing on the SQL server and returns a SELECT statement to the object that called it. 
    For most people this works correctly, however for two users on a terminal server it fails to run correctly.  What it does is not close the form, however all of the updates to the database in both dlls are run according to SQL profiler.  The .Net process that called it never seems to get a return value from the COM dll for those 2 users only.  I even tried to recreate the user's profile, but it did not help.  Note that the .Net code calls the first VB6 dll using CreateObject as well.
    The strangest thing about this is what occurred when I added MsgBox calls to try to determine what was wrong with the progress form.  I added one immediately after the form's status bas was updated to "Finished

    View Complete Post

More Related Resource Links

Interop: Get Seamless .NET Exception Logging From COM Clients Without Modifying Your Code


Using .NET objects from ASP can help you gain experience with the .NET Framework before migrating to ASP.NET. Your ASP pages will make use of the new .NET components through COM-callable wrappers (CCW). But how will you handle exceptions? This article fills you in.

Matt Adamson

MSDN Magazine January 2005

What's the problem in my javascript's code to get ClientID Property?



 Hi all.

I wirte a simple java script code to get ClientID of controls on the webform. The code is like:

<script type="text/javascript" language="javascript">

var butt = $find("<%= Button1.ClientID %>");



But when i run it , i have a problem. The probmel is:


Server Error in '/' Application.

The Controls collection cannot be modified because t

DataGrid ValidationRule or IDataErrorInfo validation code called multiple times for each data change

Following my enquiry regarding a problem in Datagrid validation, for which managing exceptions is apparently a problem, I tested the two other methods: using validation rules, or implementing the IDataErrorInfo interface. I ran into other problems there, more insidious this time. This has been done on Windows7 (32-bit), .NET 4.0.30319. 1) IDataErrorInfo When this interface is implemented, the this[string columnName] property is called four times for each modification: two times before the cell enters edit mode (with the old value in the corresponding property) two times when the new value has to be validated (with the new value) It strikes me as not really efficient, is there something wrong with my code? Here's the C# part: using System; using System.Windows; using System.Collections.ObjectModel; using System.ComponentModel; namespace DataGridTest2 { public partial class MainWindow : Window { ObservableCollection<User> users; public MainWindow() { InitializeComponent(); users = new ObservableCollection<User>() { new User { Name = "Teddy", Age = "2" }, new User { Name = "Avi", Age = "19" } }; datagrid.ItemsSource = users; datagrid.Focus(); } } public class User : INotifyPropertyChanged, IDataErrorInfo { string name; public string Name

Problem in downloading a file code.

hey dere, here is my code.....   void transfer() { string filePath = Server.MapPath("~/download"); string _DownloadableProductFileName = "mob.txt"; System.IO.FileInfo FileName = new System.IO.FileInfo(filePath + "\\" + _DownloadableProductFileName); FileStream myFile = new FileStream(filePath + "\\" + _DownloadableProductFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); string lastUpdateTiemStamp = File.GetLastWriteTimeUtc(filePath).ToString("r"); string _EncodedData = HttpUtility.UrlEncode(_DownloadableProductFileName, Encoding.UTF8) + lastUpdateTiemStamp; Response.Clear(); Response.Buffer = false; Response.AddHeader("Accept-Ranges", "bytes"); Response.AppendHeader("ETag", "\"" + _EncodedData + "\""); Response.AppendHeader("Last-Modified", lastUpdateTiemStamp); Response.AddHeader("Content-Disposition", "attachment;filename=" + FileName.Name); Response.End(); Label1.Text = "hel"; } i have two problems in this code.First while running this code i dont get the file damaged or corrupt. Second problem is dat the code exits at Response.End() and doesnt execute d last line... 

hai i am karthikeyan i have a problem in code

i want to run exe from my application .for that i had pasted my setup in my application . please give solution how to call the exe from my application .......      this is my code-------------------------------------------------------      System.Diagnostics.Process process1 = new System.Diagnostics.Process();         // Set the directory where the file resides         process1.StartInfo.WorkingDirectory = Request.MapPath("C:/Documents and Settings/user9.AIS/My Documents/Visual Studio 2008/WebSites/application/TortoiseSVN-");         // Set the filename name of the file you want to open         process1.StartInfo.FileName = Request.MapPath("TortoiseSVN-");             // Start the process           process1.Start(); -----------------------------------------------------------------   error is this------------------------------------   'C:/Documents and Settings/user9.AIS/My Documents/Visual Studio 2008/WebSites/application/TortoiseSVN-' is not a valid virtual path. &

Namespace problem (code behind "using")

Hello! I downloaded sample code from http://www.asp.net/security/tutorials/validating-user-credentials-against-the-membership-user-store-cs and imported the file "Login.aspx" file into my existing project.  This file has in the code behind the following namespaces: view plaincopy to clipboardprint? using System;   using System.Data;   using System.Configuration;   using System.Collections;   using System.Web;   using System.Web.Security;   using System.Web.UI;   using System.Web.UI.WebControls;   using System.Web.UI.WebControls.WebParts;   using System.Web.UI.HtmlControls;   I added a new page (e.g. Login1.aspx) to my project and copied the above to the top of the code behind page (Login1.aspx.cs).  In the downloaded file from the tutorial (Login.aspx) there is this line of code:Membership.ValidateUser(UserName.Text, Password.Text)And at build everything is OK! But if I add excatly the same code in my newly created page (Login1.aspx.cs) I get the following error: Error 9 The type or namespace name 'ValidateUser' does not exist in the namespace 'Krik.Membership' (are you missing an assembly reference?) G:\Krik\Krik\Login.aspx.cs 27 28 Krik The type or namespace name 'Validat

VS2010 - Problem with WinForms generated code



I'm having trouble with the code that is generated automatically by the WinForms designer, sometimes it generates code that uses the 'components' (IContainer) in the constructors of disposable components and other times it doesn't.

Here is some code. First the code that is generated in a clean new project with just one component on the form:

  private void InitializeComponent()
   this.components = new System.ComponentModel.Container();
   this.errorProvider1 = new System.Windows.Forms.ErrorProvider(this.components);
   // errorProvider1
   this.errorProvider1.ContainerControl = this;
   // Form1

Problem opening list RSS through Csharp code



I'm trying to write an application page that loads the RSS feed from a list inside the same SharePoint environment (but in another site collection).
The SharePoint environment uses basic authentication (based on Active Directory).
I do this by using the HttpWebRequest object and I pass through CredentialCache.DefaultNetworkCredentials to authenticate when opening the RSS feed, in order to pass through the credentials of the currently logged on user.

On my test environment this seems to work good. Before I got "unauthorized", and when passing the credentials it would show me the RSS feed.
Now I moved my code to another development server, and there this fails, it still gives me "unauthorized" while I can open the RSS feed manually without any problems. When trying to print the username that is passed through it returns an empty string. I found out on Google that DefaultNetworkCredentials always returns empty values for username/domain/password, but how can I possibly know then what credentials are passed through ???

Or do I have to follow another approach in order to load a list RSS feed that requires authentication ?
I cannot use a fix username/password, as I need to load the RSS feed under the same credentials as the user who opens the application page.

Thanks in advance!

AccordionPane Code Behind Problem



i'm trying to add an AccordionPane in the code behind of my project.

but when trying to set the AccordionPane.Header and  AccordionPane.Content i get an ITemplate error


here is my code:

1    AjaxControlToolkit.AccordionPane test = new AjaxControlToolkit.AccordionPane();
3    test.ID = "test";
4    test.Header = "&lt;a href=\"\" onclick=\"return false;\" class=\"accordionLink\"&gt;User email </a>";
5    test.Content = "List Files here. with download button etc.";
6    Accordion1.Panes.Add(test);


and the error i get is this:

 Error    8    Cannot implicitly convert type 'string' to 'System.Web.UI.ITemplate'  Line 4

 Error    8    Cannot implicitly convert type 'string' to 'System.Web.UI.ITemplate'  Line 5


So does anyone know how i

Security problem while debugging Infopath custom code


I have made a simple InfoPath formular, and in "Submit Options", checked  "Perform custom action using Code", and write some custom code...

Then i run the debug over this code. The InfoPath formular opened in preview mode, and i could successfully step through InternalStartup method.

I did put some data in fields and clicked on "Submit" button. I expected to be continue debugging at the beging of "FormEvents_Sumbit" method, but i got this error message:

Request for the permission of type 'Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c' failed.
   at TEST_FORM2.FormCode.FormEvents_Submit(Object sender, SubmitEventArgs e)
   at Microsoft.Office.InfoPath.Internal.FormEventsHost.OnSubmit(DocReturnEvent pEvent)
   at Microsoft.Office.Interop.InfoPath.SemiTrust._XDocumentEventSink2_SinkHelper.OnSubmitRequest(DocReturnEvent pEvent)"

After i clicked OK to this error, i got another one, a little different:

"InfoPath cannot submit the form.
The OnSubmitRequest event handler did not work.
Request for the permission of type 'Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint

jquey code resuse problem


i am using list box and button both are same code but event is different i require that a function create that use both code how to do it,and how to put in seprate file

<script type="text/javascript">
           $(function() {
               $("#<%=list_Target.ClientID %>").change(function() {
                   //$("#<%=list_Target.ClientID %>").val($(this).val());                    				
		   			    $.get("/UserControl/QC_GridView.aspx",{ QcSearch: "" + $('#<%=Hi_QcSearch.ClientID%>').val() + "" },
		        		function(data) {
           $("input[id$='Bu_ShowQc']").click(function() {
                   //$("#<%=list_Target.ClientID %>").val($(this).val());                    				
		   			    $.get("/UserControl/QC_GridView.aspx",{ QcSearch: "" + $('#<%=Hi_QcSearch.ClientID%>').val() + "" },
		        		function(data) {

Problem trying to execute ALTER SCHEMA from code


I have a visual basic application which needs to make some changes to a SQL Server database (either SQL Server 2005 or 2008).  Specifically, I am trying to eliminate a schema (e.g. MySchema) from the database altogether.  The first thing I must do is move all database objects from 'MySchema' to 'dbo'.  To that end, I execute the command:

ALTER SCHEMA dbo TRANSFER MySchema.ActionsCompleted

I am using an ODBC connection to the database.  There is a user name and password setup on the server that my application uses for all database access.  The error message I get is:

Cannot find the object 'ActionsCompleted', because it does not exist or you do not have permission.

When I run this exact statement from a query in SQL Server Mgmt Studio, it works fine.  The difference is the user (and therefore the permissions).  When I execute from the SQL Server Mgmt Studio, I am effectively an administrator, from my application, I am not.

So, I am trying to figure out what permissions I need to give my application to execute this line.  The documentation says that the user my have CONTROL priviledges over the securable (in this case the table called MySchema.ActionsCompleted) and ALTER priveledges on the dbo schema.  OK, so next I try the following (in SQL Server MGMT Studio):


Calling Javascript functions in VB.net code



This is the javascript function and I'm calling this method in my vb.net code. The jsfunction printPageZB works fine but function printPage() prints only 1 page, i want 2 pages printed. What am i doing wrong here.....any suggestions?

function printPageZB() {



function printPage() {

document.getElementById('pnlPhotoBook').style.display = 'none';


document.getElementById('pnlPhotoBook').style.display = 'block';




vb.net code

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click


Dim jsr As String = "<script type='text/javascript'>printPage();</script>"

Dim jsr2 As String = "<script type='text/javascript'>printPageZB();</script>"

If pnlPhotoBook.Visible = True Then

If (Not IsStartupScriptRegistered("Startup")) Then

RegisterStartupScript("Startup", jsr.ToString)

End If


If (Not IsStartupScriptRegistered("Startup")) Then

RegisterStartupScript("Startup", jsr2.ToString)

End If

End If


Serious problem with this code, please help


This code is going back to query some massive table with about 1 billion records, it looks as though i can use ranking functions for the query as its trying to retrieve the latest record in the history table, using the historyRef column. Can anyone please try rewrite using RANK(), i dont know where to start.


select ic.IndexCodeValue as CodeIndentifier,	
	ic1.IndexCodeValue as Identifier
	ts.[Name] as Position, 
	Current1.Divisor ,
	st.PlanNameShort ,
    ch.ProfileValue as StockCode,
	ch.NumberOfShares ,
	ch.ShareValue ,
	ch.PIF ,

from 	tblProfile i
join	tblProfileInstrument ii on ii.IndexID=i.IndexID
join	tblProfilePositionHistory Current1 on Current1.IndexInstrumentID=ii.IndexInstrumentID 

Problem with populating dropdown in code behind


Hi all, I'm having problems with this code not adding the list items to my dropdown. I was hoping someone could point out why.


On my aspx page I have:

<asp:DropDownList id="AS400_wh_c1_act" runat="server"></asp:DropDownList>

<% PopDrop(AS400_wh_c1_act)%>

In my code behind, I have:

    Public Sub PopDrop(ByVal input As DropDownList)
        input.Items.Add(New ListItem("", ""))
        input.Items.Add(New ListItem("PAGER", "PAGER"))
        input.Items.Add(New ListItem("EMAIL", "EMAIL"))
        input.Items.Add(New ListItem("STANDBY", "STANDBY"))
    End Sub

However, the dropdown list isn't adding the new items.

Anone know what I'm doing wrong?


Problem in calling javascript function from code behind


Hi All,

  how can i call Javascript function on Button click after doing some server side operation?

  Though i am using ClientScript.RegisterStartupScrip(), sometime it is working(for alert) but when i am using for display confirm message it is not showing Confirm message.

ClientScript.RegisterStartupScript(GetType(), "ConfirmMessage", "javascript:return ConfirmMessage('" + lMessage + "');");

this is not working.

Please help me out.

Thanks & Regards,



Problem with hyperlink and templatefield and calling code behind



I have a GridView with one HyperLinkField:

<asp:HyperLinkField DataNavigateUrlFields="Usr_Id" DataTextField="Name" HeaderText="Name" DataNavigateUrlFormatString="UserAccountDetails.aspx?UserId={0}" SortExpression="Name" />

When clicking on a Name item i the GridView, the user is redirected to a page using the users ID as parameter. I want to encrypt the querystring so I want to call a method in the codebehind with two parameters: First parameter = "UserId=" and the second parameter should be the value in "{0}". The datasource is a datatable.

How would I do this?

Best regards, Janhe





ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend