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

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Cannot access a non-static method

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :JQuery


For my WPF-application (using c#), i created a static method (public static void refreshGUI(string component, int getal)) in my "MainWindow.xaml.cs".
But i can't access members or non-static methods...?!

So i wrote this code to access everything in my namespace:

public static DomoticaApplicatie.MainWindow da = new DomoticaApplicatie.MainWindow();

 But when I use it, it give me an error

'The invocation of the constructor on type 'DomoticaApplicatie.MainWindow' that matches the specified binding constraints threw an exception.' Line number '10' and line position '172'.

Can someone help me?



Zahir M.

View Complete Post

More Related Resource Links

is there any impact of using static methods in Business Access layer in 3 tier applciation


is there any impact of using static methods in Business Access layer in 3 tier applciation,

Please suggest me what are the best practices and standards

Default Application "does not contain a static 'Main' method suitable for an entry point"

Hi, When I create a brand new WPF application project in Visual Studio 2010 and immediately try to run it, I get the error WpfApplication1.exe does not contain a static 'Main' method suitable for an entry point. App.xaml's build action is set to ApplicationDefinition. I think it's not generating App.g.cs. Does anyone know what's wrong?

Static Method System.Convert.ToDateTime() throws a FormatException on Windows7

Hello, There is a strange bug with the method System.Convert.ToDateTime(). Trying this simple statement Convert.ToDateTime("10/9/2010 17.39"); on a windows vista/xp works and the conversion is done. If you try that on a windows 7 than you get a format exception. Anybody has this problem? https://connect.microsoft.com/VisualStudio/feedback/details/597405/static-method-system-convert-todatetime-throws-a-formatexception-on-windows7#details Best regards. Thank you.

Calling a static method in a static class from a base class.


I have the following static class and method:

public static class GenericList


      public static List<DocumentElement> PopulateGenericList()



What is the syntax to call the PopulteGenericList() method from a base class?



Are non-static objects thread-safe in a static-method?


I am using javascript and ajax to call server side mothod.  The pagemethod can only be static function in teh server side.  But i know static methods are not thread safe across simultaneous sessions.  However, what if the static method is modifying a non-static object?

for example:

public partial class default : system.web.ui.page

Hero Superman; // create an object called superman of class hero for all user sessions independently

public static int(newpowers)


Superman.powers = newpowers;  // Is this thread safe?  Will each user not accidentally get written by another user's power values?


Error, to access method failed


Salam To all,

please find my scenario,

i have two Class projects A,B and i have Webapplication project,

the web application call Class A,

the class A make some internal operation with class B.

when a function in a class A attempts to call Entities in Class B, i have the following Error:

Attempt by method 'Txns_Model.Txns_Configuration..ctor()' to access method 'System.Linq.Expressions.Expression.Lambda<System.Func`2<Txns_Model.Txns_Entity,Users_Model.Users_Entity>>(System.Linq.Expressions.Expression, System.Linq.Expressions.ParameterExpression[])' failed.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.MethodAccessException: Attempt by method 'Txns_Model.Txns_Configuration..ctor()' to access method 'System.Linq.Expressions.Expression.Lambda<System.Func`2<Txns_Model.Txns_Entity,Users_Model.Users_Entity>>(System.Linq.Expressions.Expression, System.Linq.Expressions.ParameterExpression[])' failed.

Source Error:

Best Data Access Method


I am going to making asp.net 4.0 for first time. I was making my all application in asp.net 2.0 where I was using DAL and BLL method. In that DAL I was making Table Adapter.

Now I am going to make application in asp.net 4.0 and I am thing that my application will become more complex and huge data. Can somebody guide me about stable and fast method for data manipulate like insert, update, and delete also complex query.

I also appreciate if some tutorial for the same.

Kindly advice on which you have own experience.  

How to access multiple header rows of the gridview in Render method


I have extended a gridview to add an additional header with following two hyperlink controls "Select All" and "Clear All". These will operate on checkboxes in the data rows of the grid. I hide the column headers as I only want to show one column with checkboxes and "Select/Clear All" links. Everything is working as expected. 

Now, I wanted to add a scrollbar to my grid control, I did add the scroll bar using div but what it does is, it includes the "Select All and Clear All" links aswell. I only need to add the scrollbar to datarows and not to the header.

I am trying to extend my control to include hte scrollbar by adding div during Render function. But how will I determine or loop through header rows? How will i get the header row with hyperlinks that I created above?? In Render if I do this.HeaderRow, it gets the original column header and not the custom header. Please help!!!

Access the user session from a web method


I want to access the user session from a web method. But when I check for the session object, its nothing! How can I access the current user's session from the webmethod?

My code:

<System.Web.Script.Services.ScriptService()> _
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
 Public Class DalService
    Inherits System.Web.Services.WebService

  <WebMethod()> _
    Public Function AddFavourite(ByVal locationId As Integer) As Integer
        Dim result As Integer = 0
        If Session IsNot Nothing Then
            'DO SOMETHING
            ReportError("SESSION IS NOTHING!!!!!!!??????", "")
        End If

        Return result
    End Function

End Class  

What's the best method to control access to documents and jpgs at runtime?


I want to be able to control access to photos and PDF documents at run time.

My site sells plans for decks, porches, sheds, etc.

I want users to be able to download the photos and documents as soon as they pay for them instead of having to wait for me to email the items to them.

What's the best way to do this?  I am using VB.net, SQL Server, and ASP.net.

I am entry level to lower-middle in my programming skills, but can usually follow along.

Thanks in advance for any help. 

Can't access static member in code, but while running "QuickWatch" sees it. What the?


HI everyone,

I'm working with two Visual Studio 2005 solutions.

The first is "WinX" with a project called "WinX". There's a class in the WinX project in a namespace called "WinX" with a class "frmMain". frmMain is the main form for the application, and is always open.

We have this static member declared as so in frmMain:

public static bool IsfrmViewTaskFormOpen = false;

Enter our second solution "TasksProcessScreen" with a project "TasksProcessScreen" which has a namespace of "TasksProcessScreen" with a public class frmViewTask. The solution has the "WinX" project added as a project.

In frmViewTask, there is the following code:

private void frmViewTask_FormClosed(object sender, FormClosedEventArgs e)


   //This does NOT compile! It says "WinX" does not exists in the current context.

   if (WinX.frmMain.IsfrmViewTaskFormOpen)

Inserting the integer value in the access db using method.


hi all,

I have a Game developed in c# .net and its access db has the field as:




Mobile No:

so for this i have 2 forms,first which consist of the user information as above field except score,so in my insert query i'm providing only this fields except score.And in second form for the game in my insert query i've passed only score.so basically i want all this 5 information should be saved.so wat i've done is i've given an insert query when the user gives the wrong answer or when he quits the game or finally he wins by giving the last question as right.This is not working properly as i'm getting an error saying:'Number of quer values and destination field are not same'.But this inserts the basic information of the user except the score,also every time it takes the score as '0'.Can i use method in this so that my connection code for insertion query should be written at once and can be called in different situation whenever required.plz assist its urgent!!!!!

thanking you all.


BackgroundWorker calling COM api method get "Access Violation" error


My WPF appl need to call methods in a COM object (VC++) to do some work. It works perfectly when I call those methods   from the UI thread. As those calls take a very long time to finish, so I decided to move the interaction with COM to a BackgroundWorker. But I got an exception in one COM methods (Other methods still working fine). The error reads:

Unhandled exception at 0x62a7be37 (msvcr100d.dll) in TestApp.exe: 0xC0000005: Access violation writing location 0x0ab0f000.

The signature of the COM method is:


            DWORD size = some func get the size;

            BYTE* pSrcData = the src data address;

            memcpy((void*) pData, pSrcData, size);   //Error occured on this line


    return S_OK;


How the C# calls the method:


SubscribeToEvents Server Method Error Hresult: 0x80070005 Access Denied


Hi there;

I am developping a smo app that uses the Server.Events.SubscribeToEvents Method and actually a have a

Access Denied Error if I use it local and I have a Hresult: 0x80070005 Access Denied if I use it remotly.

Are there somebody who can help me with these items????


PD. I hope that you forgive my english.



Thinking about new C# method prototypes: object as dictionary

I recently had to write a small Flickr API. I know many .Net API for Flickr already exist but I needed one for a Silverlight application. Whatever, it's only about building some querystrings so I did it by myself. It's been an opportunity to think again about a classical question: how to pass parameters to a method ?

Imagine you have a generic method to call some Flickr functions.

MVC architecture in ASP.Net using C# and Microsoft Data Access Application block

The Model-View-Controller (MVC) pattern separates the modeling of the domain, the presentation, and the actions based on user input into three separate classes [Burbeck92]:

Model. The model manages the behavior and data of the application domain, responds to requests for information about its state (usually from the view), and responds to instructions to change state (usually from the controller).

View. The view manages the display of information.

Controller. The controller interprets the mouse and keyboard inputs from the user, informing the model and/or the view to change as appropriate.

Static Class for Beginners

In general, the members of a class can be accessed by instance of that class when they are in public, but there comes a situation to access or call members of a class without an instance and this can be achieved by declaring them as static
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