'InitializeComponent not found in current context' in the Xamarin.Forms project - xamarin

I am trying to use the xamarin.forms project in my personal project using the source rather than the nuget package.
I have added the projects to my solution and edited the reference of the Sample3 project to use the 'Xamarin' projects thai I have just added.
However I am facing the 'InitializeComponent not found in current context'. I have edited to references to point to the correct projects in this solution
There are other answers that involve this question , but they are not dealing with the scenario that is just mentioned.
Are there more projects that I need to add to the solution and edit the references?
In which project and class is InitializeComponent defined ?
What I need to do to get this working ?
EDIT : The MainPage.xaml file

From shared image , Master Solution's name is Sample2 , however your added project's Solution's name is Sample3.
If want to use InitializeComponent method , you should keep their namespace consistent .

Related

Parser Error: Server Error in '/' Application

I got the following error: "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 'nadeem.MvcApplication'`.
Source Error: Line 1: <%# Application Codebehind="Global.asax.cs" Inherits="nadeem.MvcApplication" Language="C#" %>
Right-click your Global.asax file and click View Markup. You will see the attribute Inherits="nadeem.MvcApplication". This means that your Global.asax file is trying to inherit from the type nadeem.MvcApplication.
Now double click your Global.asax file and see what the class name specified in your Global.asax.cs file is. It should look something like this:
namespace nadeem
{
public class MvcApplication: System.Web.HttpApplication
{
....
If it doesn't, then you will receive the error you received. The value in the Inherits attribute of your Global.asax file must match a type that is derived from System.Web.HttpApplication.
I had this exact same issue when I downloaded the project source into two locations. The issue turned out to be by downloading the source it altered the sites virtual directory location and since I had not rebuilt the second source there were no DLLs there.
To fix this issue open the project you wish to build and go to the
web sites properties (Project menu)
Create the virtual directory for
the project.
rebuild the project.
Fixed
After going through all of my projects in my Solution to set the compile to output to bin\debug and bin\release, this problem started for me. I finally realized that the startup project (i.e. the project with global.asax) needed to output to bin only.
Since normally you create an MVC project the Global.asax markup has something like the following:
<%# Application Codebehind="Global.asax.cs" Inherits="StackOverflow.MvcApplication" Language="C#" %>
Have you placed the Global.asax.cs in another project? If you have remove the CodeBehind="..." declaration from Global.asax and change the Inherits="..." declaration to reference the correct namespace and classname as it is defined in Global.asax.cs file.
If you haven't moved it try a Clean and then Rebuild of the Project in Visual Studio using the context Menu on the Web project. That worked for me when I got this error.
Go to Project Properties
Look Output Path in the Page bottom
Change path to: bin\
Save and Run Project
The case is solved, but you may also get this error if your project is building to a different directory than IIS_Virtual_Directory\bin and dlls are missing.
As Kevin answered. I was changing the project name and namespacing in my MVC project. When I ran the application I got the same error "Line 1: <% .....".
To fix this, I needed to update the namespace within Global.asax (Right Click -> View Markup) then in the Inherits attribute update this to "<correct root namespace for MVC project>.MvcApplication".
For me Deleting the dlls from the BIN folder and then building the project worked
simply just copy the project to another location and run it will work i think problem because of the cleaning is not correctly done and there may be setup change in the output /bin
When I got this error it was after I deleted and recloned a Git folder; what happened was I forgot to build the solution in VS2010. As soon as I built it, everything worked fine. Sometimes it's something really simple like that.
In my situation I was getting this same error. I am using git along with Source Tree for version control. In my case git had been enabled in the project, but I wasn't using Visual Studio to stage my commits, etc .. I was using Source Tree. This doesn't really matter what I was using the problem is that visual studio had put the following line into my gitignore file:
#Build Results
[Bb]in/
That was ignoring the bin folder so my bin folder never got pushed up to the server, once I removed that line and committed the entire bin directory and pushed it up to the server and then went to the server and did a git pull. The bin folder showed up and everything started working!
BTW, my final gitignore file (#Build results) section ended up looking like this:
# Build results
[Dd]ebug/
[Rr]elease/
x64/
build/
[Oo]bj/
Im still unsure if I need the Obj folder to be pushed to the server, but everything is working fine now.
In my case the solution was the next:
Verify the markup of Global.asax, in the attribute Inherits I had this Inherits="NameOfMyProject.Global"
Then, verify the Global.asax.cs and I found this:
public class Global_asax : System.Web.HttpApplication
Therefore, I changed the attribute Inherits in my Global.asax, and finally the markup was the next:
Inherits="NameOfMyProject.Global_asax"
Also, I started the: ASP.NET state service, in the Administrative Tools. Then, my app run normally.
I was learning from a video resource and ran into this error when told to hit Ctrl-F5 in the View in order to load it directly. By doing this, I ran into the same error message you posted.
In order to fix this, I built the solution (Build > Build Solution or Ctrl+Shift+B) and then retried.
In my case, it helps:
if you use a folder other than the default project ( naprmer on the D drive , in the case of Windows), then change to the default folder , create the project , run it. Then again, you can create projects in the folder in which you want . Strange. But this has helped in my case.
This happened to me when i was trying to merge two solutions.
the problem was the namespace was not well configured in all files.
one part of story solved with #Kevin Aenmey answer but many other's ... not!
so the only way for me was to search for old namespace in the whole solution and replace them all with new namespace.maybe not the best option but in case of bad luck works nice
This error causes when Namespace is Renamed.
-
Go to Folder Explore ( Don't Use Solution Explore) . Find Global.asax File
.
Open File (in Notepad / any editor) and Change Replace Old namespace name New Namespace
.
Save It should work now..
I had the same problem and that was because I didn't build the solution. Rookie mistake. Just: build solution (Ctrl + shift + b)
I had this problem after adding a new project to my solution. The solution built, no problem - but then bombed at runtime.
It turned out that the new project was set to target .NET 4.6.1 by default, whereas everything else in mhy solution targets .NET 4.5.
Changing the target framework in the new project to .NET 4.5 to match the others fixed the problem.
(thanks for no warning on that one Microsoft guys)
I use FTP to upload DLLs of my site on the server but sometimes this error happen when the main DLL of the website has not been uploaded correctly on the server.
So I recommend you to rebuild you project and re-upload main DLLs on the server again.
In our case - deleting all the contents of a published intranet site, and republishing the project that worked fine in debug fixed the problem.

VS2010 MultiProject Template

How do I add a specific, NON-PROJECT Folder to a MultiProjectTemplate?
I.e I add a projectCollection to TemplateContent with all of my involved projects as ProjectTempateLink s inside.
How do I add a non-project related folder?
I've tried Folder both inside TemplateContent and inside a Project inside TemplateContent, but it doesn't work.
Looking at the schema http://msdn.microsoft.com/en-us/library/xwkxbww4%28v=VS.100%29.aspx it should be supported? Or is there an issue with using ProjectCollection and another tag inside TemplateContent
Not so much solved, as a workaround made:
I made a blank C# project, included the files necessary.
I then made a single project-template of this, then added it to my multi-project template.
It's silly that It's not possible to add a non-project related folder, but hey...

Xcode custom project template creates only references to files

I tried to create a custom project template for setting up unit testing.
The problem is that when i create a new project based on this template it creates references to the template files :
When i edit a file, it changes my template files instead of my actual project files !
When i delete my template, files from my actual project becomes red !
The project template is in :
/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Project Templates/Application/Test-based Application
Reading some question on stack overflow i tried to install my template project in
/Library/Application Support/Developer/Shared/Xcode/Project Templates
But i cannot see my template when i create a new project.
Can anybody help ?
Thanks,
Vincent
You might be interested in my Xtemplate project on GitHub. It’s a simple script that will set up a new Xcode project with decent defaults, it features a unit testing target with OCMock.
there are several reasons but the most important is because your template info plist identifier is not unique! as you said you have put the template in /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Project Templates/Application/Test-based Application
and then moved the same template in other place. xcode has seen the identifier number in the first location and ignores the second. change the identifier and give it a try.
why dont you try the main template folder:library/developer/xcode/templates ?

Visual Studio Solution Template - Link Source Control Projects

My team is creating some standard VS solution templates. We have a well-defined project structure, resources, etc. that we need to use every time we start a new project and this is the perfect solution. The basics work nicely.
However, as well as defining folder structure (etc.) it would be nice to be able to import a number of projects from VSS/TFS. We have a number of shared assemblies that will be used by all projects and it would be awesome to add a reference to these projects when creating a new project via our template. Can anyone tell me if this is possible and, if so, how it can be achieved?
I think there are 3 types of items you might want to templatize (is that a word?).
New Solution
New Project added to a solution
New item added to a project
I'm not sure whether its possible to add existing projects to the solution that is created when a project template is run. http://msdn.microsoft.com/en-us/library/ms185308.aspx shows how to create multiple project templates. You may have to either manually add them to the solution or create a script that modifies the .sln file to do that part.
Adding an assembly reference to either a project or item template is easily doable. The project template is pretty simple since you just need to modify your .vstemplate file for the project template(s). See http://msdn.microsoft.com/en-us/library/ms171405.aspx for reference.
Adding a new assembly reference when you add a new item from a template is a bit harder but can also be done. See http://msdn.microsoft.com/en-us/library/ms185290.aspx for more.
Have fun!

VS2008 Solution Template

In the past I have created ItemTemplates for classes that I regularly use in VS2008. I want to create a template for a solution that will have two projects, a Web Site and a Class library.
I have not been able to find any clear instructions on how to do it. I am not sure if it can be done. Does anyone have any links to a possible solution.
Thanks
There are detailed instructions on MSDN for creating custom project templates in VS2008.
-Edit-
There is no such thing as a "Solution Template." There are Item Templates (for new files), and Project Templates. However, I think what you may be looking to do is to create a specific type of Project Template called a Multi-Project Template.

Resources