Could not load type 'XXXX.aaa' - c#

Hi,
I am having Could not load type error when I release my code into live environment. If I remove the code Inherits="CheckIEBrowser.Check" that gets rid of the error, it displays the page, but it doesn't work as it should.
Thanks in advance
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace CheckIEBrowser
{
public partial class Check : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!(IsPostBack))
{
...

Make a copy of Check.aspx and its CS fle to your local
Delete Check.aspx and Check.aspx.cs manually from directory
Clean Solution
Right click your solution add new form and name it as Check.aspx
Copy your local saved check.aspx contents to Check.aspx that we created newly (except line 1 )
do the same for check.aspx.cs also
rebuild your solution
Than try
if its not work, delete CheckIEBrowser.sln file and try

Related

The type or namespace name does not exist in the namespace (are you missing an assembly reference?)

I know that this question has been already asked, but I cannot find anything that can help solve my problem.
I want to connect my aspx page (Retete.aspx) to a Microsoft SQL database. I'm getting this error on Retete.aspx.cs:
Error 1 The type or namespace name 'GlobalClass' does not exist in the namespace 'ProiectSera' (are you missing an assembly reference?)
The error points to this line of code:
ProiectSera.GlobalClass.Update(ValRefTempSol.Text, ValRefTempAer.Text);
Where ProiectSera is the project name, GlobalClass is the file where I make the operation on the db.
My using statements are:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ProiectSera;
The Target Framework is set to .net-4.5.
What should I do to solve this error?
Update
My GlobalClass.cs is:
using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.IO;
using ProiectSera;
using System.Data.Services;
namespace ProiectSera.App_Code
{
public static class GlobalClass
{
static public void Update(string _param1, string _param2)
{//function to update}
}
}
App_Code is a folder where GlobalClass.cs is. I tried and
ProiectSera.App_Code.GlobalClass.Update(ValRefTempSol.Text, ValRefTempAer.Text); //
but I had the same error. And I put the GlobalClass.cs in the project's root. I also removed the .App_Code from namespace ProiectSera.App_Code
UPDATE1
My Retete.aspx.cs is
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ProiectSera;
using ProiectSera.App_Code;
namespace ProiectSera
{
public partial class Retete : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSave_Click(object sender, EventArgs e)
{
string intValRefTempSol;
string intValRefTempAer;
// intValRefTempSol = ValRefTempSol.Text;
// intValRefTempAer = ValRefTempAer.Text;
// ProiectSera.App_Code.GlobalClass.Update(ValRefTempSol.Text, ValRefTempAer.Text);
GlobalClass.Update(ValRefTempSol.Text, ValRefTempAer.Text);
}
}
}
Your GlobalClass is in the namespace ProiectSera.App_Code.
So the class name is ProiectSera.App_Code.GlobalClass
Make sure you don't have a ProiectSera class in the ProiectSera namespace also, otherwise if declaring using ProiectSera on top, it'll try to use it (as a general rule, don't name any class the same as your namespace).
If that still doesn't work, you may want to try using the global namespace:
global::ProiectSera.GlobalClass.Update(ValRefTempSol.Text, ValRefTempAer.Text);
and see if that works: if it doesn't, and GlobalClass is in the same project, then there's something else you haven't shown us
Update
The only other thing that comes to mind, if you are positive that both files are on the same project/assembly, is that GlobalClass.cs is not being actually compiled. Make sure the Build Action is set to Compile (you can see the build action right clicking on the GlobalClass.cs in the solution explorer and selecting Properties).
If you are using VS.NET:
Right click on the References folder on your project.
Select Add Reference.
Select the .NET tab (or select the Browse button if it is not a .NET Framework assembly).
Double-click the assembly containing the namespace in the error message.
Press the OK button.
Ensure the following...
That you have a project reference to ProiectSera from your web application, if it's in a separate library. If GlobalClass is in the web application project itself, you won't require this, but if GlobalClass is defined in a separate library in the same solution or elsewhere, then you're going to need to add a reference to that external library in your web application.
Ensure that ProiectSera should not be ProjectSera (if it's a typo).
Ensure that you have your ProiectSera using statement in place at the top (using ProiectSera;). Assuming that this is the correct namespace. Check the namespace of your GlobalClass class and use that using accordingly in the class that wishes to use its functionality.
Then, simply call this in your code, assuming that Update is a static method of GlobalClass.
GlobalClass.Update(ValRefTempSol.Text, ValRefTempAer.Text);
EDIT: given that you've now posted your GlobalClass code, you can see that the namespace for this class is ProiectSera.App_Code;. So you need to have that as your using statement in the other class using ProiectSera.App_Code;. And then call it via simply GlobalClass.Update, as mentioned above.
If you don't understand how namespacing works in C#, then I recommend you check this out (https://msdn.microsoft.com/en-us/library/dfb3cx8s.aspx).

Identifier expected in C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace PageProcessingDemo
{
public partial class : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
i haven't done anything yet ,but it still showing " Identifier expected ",and pointing to ":" when double clicked.
You haven't specified class name.
Change your code to something like this:
public partial class MyPageClass : System.Web.UI.Page
P.S: Also, you have said that:
i haven't done anything yet
I am pretty sure that somebody has removed name of the class.
Additional details:
Try to add new WebForm to the project. Set the name of form to WebForm1.After clicking OK, VisualStudio will create three or two files depending on the type of the project:
WebForm1.aspx
WebForm1.aspx.cs
WebForm1.aspx.designer.cs (WebApplication project)
The *.aspx files are the markup and the *.aspx.cs files are the code-behind files. Code-behind files handle the .NET code for any server-side controls in the *.aspx files. And Asp.Net will generate your code behind files as partial classes like that:
public partial class WebForm1 : System.Web.UI.Page

How to find a function of application with ollydbg?

Let's say i released the application below.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("Hello World!","Message Box");
}
}
}
Now here is my questions:
How to find the function of button which is responsible to show
message box after pressing the button with ollydbg?
How to disable the button click ?
Notes:this must be done with ollydbg only. Assume that i don't have access to the code.
A step-by-step example would be greatly appreciated.
Using Olly or IDA is a lot of work for nothing.
Use .NET Reflector for decompilation(there is 14-day trial) and download Reflexil plugin to be able to modify code.
Finding the place should not be too hard since you have decompiled sourcecode.
If you cannot find the place you can try one of these:
Connect reflector to Visual studio
Export source code and just run it from Visual studio
If code is obfuscated I cannot help you there, you just must start playing with it till you defeat obfuscation
With Reflexil addon you can simply delete/modify the function
Why not use IDA? You can "easily" nop out the function.

Intellisense stopped working for Linq to Entities

I have this simple code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.Linq;
using GadNameSpace;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
GadEntities db = new GadEntities();
var images = db.Images.Where(x => x.isApproved == true).ToList();
Repeater1.DataSource = images;
Repeater1.DataBind();
}
}
Now if I'm trying to edit this line:
var images = db.Images. <--this is where intellisense is not working...
It worked before. Same file, same project, same Solution.
If I'm writing the code manually and run it, its working fine.
I tried start > cmd > "devenv /ResetSettings"
I tried to restart pc also.
The problem is with Linq intellisense only! for anything else intellisense is working fine...
Any good ideas?
Usually this happens to me when a reference to System.Data.Linq.dll is missing from the module.
I bet you have your data context in yet another assembly where the reference is set correctly (so that the code works when you compile it) but in the same time the reference is missing from the web application (and thus VS does not show the intellisense).
Sometimes, reference of EntityFramework could be missing. Please make sure that the same exists in the project you're working on.

linking a new windows form with an existing project in c#

I have a c# problem. I have created a project called 'classproject' and I have added several forms to project successfully and successfully ran the program, but there is this other windows form that I just added and when I double-clicked on the form, it took me to the code view and brought out this:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class demo : Form
{
public demo()
{
InitializeComponent();
}
private void demo_Load(object sender, EventArgs e)
{
}
}
}
Now, my challenge is that the name of the project is meant to show by default after the namespace as in "namespace classproject" instead of "namespace WindowsFormsApplication1". Please can anyone help me out, what am I meant to do because have tried everything possible. Even if I change the name myself its still going to flag error... someone please help me as soon as possible.
I'm not sure exactly what your issue is. If you change the namespace manually in the code to classproject it should be fine. What error are you talking about? You would also need to change the designer code file as well (probably called demo.Designer.cs).
Just a side note as well. Standard naming convention for C# is to use Pascal-case (as in ClassProject).
You must change namespace in ALL files that was generated by Visual Studio. You can do it manually, or just set cursor on "WindowsFormsApplication1", press F2 and enter new name.
Optionaly you can also change namespace in project properties on Application tab - then all new files added to project will also have namespace that you set there.

Categories

Resources