I have a Website Solution and I want Convert it to Web Application.
When I Transfer Base files (like DAL,BLL(.cs files my mean)) and Build My Solution it's working.
But When I Add other files that use the Base Files I have Many Errors Like (CS0246,CS0103,CS0118,CS1061).
I see this answer like:
https://msdn.microsoft.com/en-us/library/w7xf6dxs.aspx
and
Why am I getting error CS0246: The type or namespace name could not be found?
I want to Know if I build My Solution and Visual Studio Create .dll files why I have error that say not found X.dll? and how can it be fix?
You will have to go through and fix each error in turn as you migrate.
https://msdn.microsoft.com/en-us/library/aa983476(v=vs.100).aspx
I usually create an empty Web Application project and then copy the output into the same folder as my Web Site. Then I open the web application project in tye same solution as my website. Now you have two Projects for the same location.
Now enable the "show hidden files" option and "include" all the files in your project. At this point you will get loads of errors... Make sure that you first right-click on the root of your Web Application and select "Upgrade to Web Application" as this will do much of the grunt work for you.
In Web Applications you get Partial classes and when generated they are clashing with each other. In a Web Site you can have duplicate namespaces and class names, in a web application you can't. You need to go through all of your *.aspx and it's associated files and rename all of the class snakes to be unique.
This will start removing the errors although it may take some time to get through them all.
Related
First of all, I know ASP.NET MVC, but have very little/no experience with Web Forms. I inherited a site today that is a Web Forms site. Once I got to looking at it, it was quickly apparent that the .cs (code behind) files that go with the .aspx files are missing (or hidden somewhere). I get an error page in the browser when I try to build because the files are missing. The curious thing is that the live site is totally fine...so surely those files exist somewhere?...or maybe you don't need them?...like I said, today is my first day trying to tackle an old Web Forms site.
The files are not present in the local directories nor in Visual Studio. Am I missing something...am I crazy...am I just a newb? I attached some pics.
I am new to Visual Studio. I am using VS 2010 and I cannot find the main method of my C# application. After browsing a bit, I found out that it is created during the compilation phase and is located in obj/{Debug/Release} folder. However, I am unable to locate the folder on my system.
My solution explorer and properties window look like this:
And the corresponding directory (path from the properties window in the above picture) doesn't have obj folder.
Can somebody help me locate the obj folder? I want to check the flow of my program.
Any help is greatly appreciated.
Thanks!
I cannot find the main method of my C# application
A web site doesn't have a "main" method. It usually has global initialization hooks, but nothing quite like Main.
It also looks like you've created a "Web Site" project rather than a "Web Application" project - I've never fully understood the difference, but I suspect you may find that a web site project isn't built in quite the same way, so you may never see the output folders you were expecting. In particular, I'm not seeing anything that would correspond to where I'd expect those initialization hooks to be. You may wish to create a new project as an ASP.NET web application instead.
(I'd update to a more modern version of Visual Studio at the same time, if you possibly can. There's a "community" edition of VS2013 or the release candidate for VS2015...)
You have created an empty WebSite not WebApplication so by default in WebSite there is no bin folder until and unless you explicitly add bin folder or you Add Reference to dll;
In WebSite your main folder for code is App_Code folder where all your .cs files are placed.And in WebApplication all of your code is converted in a dll that is placed in bin folder.
I have a web project created in Visual Studio 2012 that consists of a project as well as a web application. Both share the same solution. I'm basically just trying to get the DLL that's created in the project to be passed to the bin folder of the web application automatically with each build. I know it can be done because it's like that on other web projects I have, but I don't know why it works on some and not on others. I've been searching the internet hours, but have had zero luck. It seems like a very simple setting change so maybe someone on here knows.
I finally found the simple, one line answer I was looking for. I'll post the answer here to help others...
Go to Properties (for project in question), click on Build Events, enter the following into the Post-Build Event Command Line:
Copy /Y "$(ProjectDir)bin\debug*." "$(SolutionDir)bin*."
In this case, ProjectDir is the root directory of the project and SolutionDir is the root directory of the web application.
I have created webservice and published it on local machine. Then I have uploaded it on server.
Now while I tried to access webservice it gives following error :
Parser Error Message: Could not create type 'webservice.myservice'
Source Error:
Line 1: <%# WebService Language="C#" CodeBehind="myservice.asmx.cs" Class="webservice.myservice" %>
I tried This link but unable to solve my problem.
What should I do?
I don't know if this is dragging something up from the dim and distant past, but I had this problem. I fixed it. So I thought I'd to share it.
When you create a web service in Visual Studio (I'm using 2010 but I'd imagine it's the same for others), it creates a file called Service1.asmx
You will be tempted to rename it to MyService.asmx (or whatever).
Then you'll look inside and see the line
public class Service1: System.Web.Services.WebService
which you'll change to
public class MyService: System.Web.Services.WebService
and then when you try running it, you get the error
Could not create type 'MyProject.MyService'
Because it still thinks the class is called Service1.
If you right click the .asmx file and select view markup, you'll see it still says:
<%# WebService Language="C#" CodeBehind="MyService.asmx.cs" Class="MyProject.Service1" %>
change it to
<%# WebService Language="C#" CodeBehind="MyService.asmx.cs" Class="MyProject.MyService" %>
save it, try it.
It worked for me.
I had the same problem and looked for it for a long time!
I tried a lot of things including the following:
Frameword version incorrect
A whole list of things that could be wrong
None of those worked for me. After some searching, testing and cursing, I finally found the problem: The application (webservice) was incorrectly hosted.
Let me explain with a little background:
I had a project containing two solutions: One solution was the website that I made (html, javascript, etc), the other solution contained a folder with the business logic, the database model and the webservices. Obviously the webservices folder contained my .asmx files and code-behind for them.
Project
Data Core
Database Model
Business Logic
Webservices
myWebservice.asmx
Website
I was hosting these in the following way:
My website was hosted as a new site with the website folder as root folder
My webservices I was hosting as an application in my website, with the webservices folder as root
More visually:
IIS 7
My Website => Pointing at the "Website" folder
Webservices Application => Pointing at the "Webservices" folder in the Data Core
This resulted in the following url "http://website/webservices/myWebservice.asmx", which gave me the "Could not create type" error.
Now, after playing around a bit I tried hosting my webservice application starting with the data core as root, instead of the webservice folder.
Visually:
IIS 7
My Website => Pointing at the "Website" folder
Webservices Application => Pointing at the "Data Core" folder.
Obviously using the same url as before would give me a "File not found" error. However, using the following url "http://website/webservices/webservices/myWebservice.asmx",I finally got my working webservices page!
A small url breakdown:
http ://website/ => My website from the "Website" folder
webservices/ => Equivalent to the "Data Core" folder
webservices/ => The "webservices" folder in the "Data Core" folder
myWebservice.asmx => The webservice file in the "webservices" folder, in the "Data Core" folder
I assume that because I was hosting my webservices directly from the "webservices" folder in the Data Core, that the server could not find the compiled DLL of the webservices (which resides in the "bin" folder), since I was hosting at a deeper level.
After changing the configuration and hosting the webservices from the "Data Core" folder, the IIS server could "see" the bin folder and host the webservices succesfully. When using the correct url that is ^_^
I hope this is clear and helps you with you problems!
Another thing that can cause the problem. Is not creating an application for the project through the IIS itself. If the code is already on the server navigate to it in IIS from the left Connections pane. If the web site directory is still a yellow folder icon (and not a globe icon) you need to right-click on it and choose Convert to Application otherwise follow these steps...
Start -> Search For IIS
Open It!!
Right Click on the Default Web Site or the web site you are planning to publish the service to it.
Add application... Enter an Alias ex. "MyWebService" ... Choose the physical path. in my case was C:\inetpub\wwwroot\MyWebService which is my default web site path.
Then when you publish through Visual Studio choose that folder. or just copy your code files to it.
I'm fairly certain this is just a summary of what Glenn said, but I ran into this issue because my application was created from the directory one level too high in the directory structure.
For example, my web service was in SiteProject_1/SiteProject_2/service.asmx
Originally SiteProject_1 was what I converted into the application within IIS. I was able to resolve the issue by removing that application within IIS and instead making SiteProject_2 into the application.
I was having this problem this morning and Google landed me here, but none of these answers worked for me. But I did figure out what was wrong - at least in my case - so I thought I'd share it in case it helps others.
I had a web service that had been working fine for months in a solution with other parts of the application that I work on. Yesterday, I needed to fix something in a release branch, so I opened Visual Studio on a copy of the solution in another directory. Visual Studio decided to be helpful and silently remap all my virtual directories in IIS to where the programs would be in the release folder (if I had bothered to build them, which I hadn't). Now when I tried to hit my web service, IIS was pointing to the release version which had the asmx but no bin folder.
Opening the Web properties tab in my development solution and clicking the Create Virtual Directory remapped it back to the development version and all was good with the world again.
It has been two days and I haven't been able to make this application work in the hosting computer. This application is in a subdirectory and is written in C# the other application is C#. It work just fine down here in my development computer. I have been trying the following.
1.I made the changes to the web.config so it doesn't conflict.
(seems to be fine)
When I created the application was created with Version 3.5. I downgrade to 2.0
I have been recompiling, being sure that the .aspx file and the .cs file it's under the directory.
Waht Am I missing.
Any ADVISE/Comments or questions please let me know. This is frustrating. Below is the link and the error I get
http://www.martinesexpress-inc.com/PhoneControl/Default.aspx
Server Error in '/' Application.
Parser Error Description: An error
occurred during the parsing of a
resource required to service this
request. Please review the following
specific parse error details and
modify your source file appropriately.
Parser Error Message: Could not load
type 'ElLogPh._Default'.
Source Error:
Line 1: <%# Page Language="C#"
AutoEventWireup="true"
CodeBehind="Default.aspx.cs"
Inherits="ElLogPh._Default" %> Line 2:
Line 3:
Source File: /PhoneControl/Default.aspx Line: 1
Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET
Version:2.0.50727.3053
You're publishing to a sub directory (PhoneControl) of the application root (http://www.martinesexpress-inc.com/). If PhoneControl is not an application in IIS, then it will won't look for assemblies in http://www.martinesexpress-inc.com/PhoneControl/bin but http://www.martinesexpress-inc.com/bin.
Basically, in a nutshell, the dll that is compiled for you (and comtains the class 'ElLogPh._Default') is not being found. There are a few reasons for this to be the case, but here is the first that comes to mind, and the most likely:
The first question is, are you aware of how a Visual Studio web site project corresponds with an IIS application? This is incomplete, but the simplest description of the first thought that comes o mind.
When you create a web site project in Visual Studio and Build it (or publish it, since VS's publish process includes building it first) all of the code behind is compiled into dll's that are put in to the "bin" directory.
When you publish this out to the web site, an IIS application has one and only one bin directory. Any bin directories in nested folders are not treated as actual bin directories.
So, if you built this as a different project and just copied it into the original folder, your structure would look like this:
\Parent
\Parent\Bin
\Parent\YourNewApp\
\Parent\YourNewApp\Bin
I'm thinking that the ElLogPh._Default class is in a dll inside of \Parent\YourNewApp\Bin.
The resolution to this would be to go to the IIS manager and make \Parent\YourNewApp an application.
If it sounds like I'm on the right path, instructions for creating an application in IIS are found here: http://www.affiliatewiz.com/support/appstartpoint.asp
I don't know if this will help, but are you building in Release mode?