To explain my problem, an example is better.
I have an ASP.NET MVC 3 controller action who return a view with an object as a Model.
This object, contains some business properties used by the view like a list of contacts, for example.
If i call a property of my object in the view (from Model.) and, after that, I change this property name, the debugger of visual studio say nothing.
However, this one should alert me that I try to load, in the view, a property who doesn't exist !
Moreover, when i compile this project, it passes until i try to render the view !
Is there a way to check that from visual studio ?
Thank's by advance !
You could enable compilation of your ASP.NET MVC views by putting the following in your .csproj:
<MvcBuildViews>true</MvcBuildViews>
This way you will get a compile-time error.
You can compile in Release mode to highlight all deal breakers. takes a bit longer to compile but catches everything, right down to properties in Views and even takes you to the line in the View that's causing the problem(s).
Related
I've had this long time problem that I can't view as text the main form for a project I inherited. Even if no other forms are open.
How can I debug the cause of this error message? What options do I have to fix it?
I found one related newsgroup post http://embarcadero.newsgroups.archived.at/public.delphi.ide/200906/0906193960.html but this only addresses the form inheritance cause, and doesn't explain anything about linked modules. I don't believe I'm using form inheritance.
I do have a DM (data module) for the project, and the form does load a couple of images from the dm through properties of a TTreeView on the form--does having a data module automatically mean I can never view as text a form in Delphi (aside from viewing the form as text in notepad)? It doesn't seem to matter whether my DM is open or closed in the IDE.
I also found one SO question with a related title (Module %s has open descendants or linked modules. can not reload) but the question itself and it's answer is not particularly relevant.
This is sometimes caused by a form that inherits from another form in your project (or the gallery) (known as Visual Form Inheritance in the documentation, IIRC). The IDE doesn't know how to find the base class for the form; it needs that opened before the descendant form. For instance, this can cause the same error if the unit containing TMyBaseForm isn't opened first in the IDE, particularly if the base (ancestor) unit is not included in the project first:
unit SpecialForm;
interface
uses
Forms, { all the other usual stuff }, BaseForm;
type
TMySpecialForm = class(TMyBaseForm)
private
public
end;
You can tell if this is the case by looking at your form's class declaration - if it descends from anything other than TForm, this is probably the cause of the error.
(Another instance of it happening is often when using a datamodule, because the base TDataModule .DFM isn't available. Attempting to view the datamodule .DFM as text will cause this error every time; the solution is to close your project and use an external editor such as Notepad or Notepad++ to edit the .dfm for your datamodule.)
I've had this issue occasionally, perhaps when I've used Frames, but my latest instance didn't involve Frames nor Data Modules nor inherited forms.
After an enormous amount of work creating a copy of the form (which copy didn't have the problem) and renaming the original unit and the form itself (which initially seemed to solve the problem), it turned out to be a live binding between forms.
Specifically, in my FMX application Form A has an options page with a TSpinBox that allows the user to set the minimum value for a TTrackBar on Form B (which was the form giving me grief). So the TSpinBox.Value was set to update the TTrackBar.Min field by means of a live binding. Closing Form A, or removing that live binding (and replacing it with an event handler to do the same thing) solved the problem.
I'd like to call upon the answer of Phillip J. Rayment and ADD that you don't have to have live binding to have this problem occur. It's sufficient to have custom control (class) of which you have an instance in another form. Then the RLink32 problem can appear and won't be solved until you close the form where you have the instance. The problem I experienced gave the following messages:
-RLink32 (during building)
-Access violation in module designide160.bpl` (if I made a modification to the problematic form)
-The module has open descendants or linked modules” error (if I tried to 'View as Form')
Is there any example of binding any sort of collection to a TableLayout in android? I keep receiving the message/warning that binding failed for attribute ItemSource LocationQuantities. All of the other bindings to the view model work as normal, but the list doesn't bind to the TableLayout. At first I thought my problem was binding to a dictionary but I was able to bind to a dictionary with other Mvx layouts (listview etcs.)
I can't seem to find in any of the N+ code examples or anywhere else on the web where a TableLayout is actually used in an mvvmcross app. I'm sure I'm just doing something stupid simple wrong here.
<Mvx.MvxTableLayout
p1:id="#+id/PartLocationQtyTable"
p1:layout_width="fill_parent"
p1:layout_height="wrap_content"
p1:layout_below="#id/PartDetailPriceLayout"
p1:padding="5.0dp"
local:MvxBind="ItemSource LocationQuantities"
/>
I've tried the above as well as with a custom template. The above example just uses a list of strings.
Any help would be appreciated
The only obvious problem I can see with your code is that it uses ItemSource whereas all the list-based layouts use ItemsSource - see MvxTableLayout.cs#L89
Beyond that, I guess you'll also want to make sure that your templates for TableLayout are TableRows - so that they can be loaded as rows. Obviously we can't see your item templates currently as you've not included them in the question.
I've got to admit TableLayout isn't something I've ever personally used in a production project - just not something I've yet needed to use.
I know, that views are compiled on the fly, but when exactly does it happen? First compilation occurs at first request, if I'm not mistaken. But what about when I modify aspx/cshtml file, what happens then?
Is it possible to somehow control this behavior without using aspnet_compiler.exe?
The problem I'm having is that I modify my controller/viewmodel and load them as a separate assembly. When I refresh page I get this error:
The model item passed into the dictionary is of type 'Test.Controllers.AController+IndexViewModel', but this dictionary requires a model item of type 'Test.Controllers.AController+IndexViewModel'.
The difference between these models is the assembly name (not shown in this error), so I need to recompile views against my updated viewmodel.
It happens on the next request after the modification.
If your ASPX Views have codebehind then there's 2 step compilation happening. First the codebehind class is compiled as part of the project, next the ASP.NET runtime creates another class that inherits from the precompiled class. If you change the controller to pass a different model class but don't recompile your project it won't work because the precompiled class still references the class from the old assembly.
So, if you use codebehind, the project compiles a class that inherits from ViewPage<TModel>, and if you want to change TModel you have to recompile the project. If you don't use codebehind this is not an issue, because TModel is determined at runtime.
I have generated a solution in C# 2010 by way of the Artinsoft conversion from VB6.
When I open the new solution in C# I right-click on the forms but there is no "View Designer" option. I assume this is because something is failing to compile. What could be the problem and how should I fix it?
Try a clean and rebuild
Make sure you have proper designer.cs file
Make sure the initialize method is called from the constructor of your Forms.
Make sure if there are any custom dlls they are in right places.
Better create a new app in Windows forms and check how the things are arranged. so that you can compare the conversion.
I would not expect that from a failure to compile, but rather a failure to convert properly. Even if the class doesn't compile, if it's a form you shouldbe able to see and edit the form portion.
The reason should be marked in the error list if it's failing to compile. It's more likely that it's created it as just a class (that doesn't inherit from Form).
Check that there's a MyForm.Designer.cs (where your form name is MyForm) and also check that the declaration of the class in MyForm.cs inherits from form
public partial class MyForm : Form
If this isn't the case, it hasn't converted properly, so you may have to inherit from form, drop on the UI controls again and hook them up to any events
Have you tried running Visual Studio as Administrator (elevated rights)?
Can you try Shift+F7 key combination?
I am getting the following error in my mvc application when I am doing the paging functionality
CS1061: 'System.Collections.Generic.IEnumerable' does not contain a definition for 'HasPreviousPage' and no extension method 'HasPreviousPage' accepting a first argument of type 'System.Collections.Generic.IEnumerable' could be found (are you missing a using directive or an assembly reference?)
please tell me what to do and what is that Model.
This reminds me of the PaginatedList<T> class found in the Conery et al MVC 1.0 Wrox book... (And probably also found in the NerdDinner app.) I actually have this book right here next to me and have this section tabbed. And sure enough they have a property called HasPreviousPage, which leads me to guess this is what you are working with? It is in Chapter 1, which is a free download. (Google for it.) I highly recommend taking a look at this chapter, or at least this section, as there are many other helpful suggestions and tips to be found!
Best of luck!
I think that you may be missing a namespace import.
Is HasPreviousPage a method or a property? If it is a helpermethod on the type of list you are returning then you need to import that namespace in your aspx file (or in the web.config to reflect on all pages)
You need to change the controller to use Paging, check out http://blogs.embarcadero.com/johnk/2009/04/02/38871 for more info
EDIT: To clarify, so somewhere in the Controller, you're gonna see something to the effect of "return View(someModelObject)" - you need to use PaginationHelper.AsPagination here to turn someModelObject into a pageable object
There are a few possibilities here:
First off, Model is your object, or class. HasPreviousPage is a method or function in Model.
Here are some possibilities:
Model is not defined because the file is not included in the page
HasPreviousPage does not exist as a method
HasPreviousPage is actually a property and needs more information to extract data (as tster is saying)
The signature for HasPreviousPage is incorrect. You are sending too much, or not enough data.
My guess is it's either a boolean property, or a method that returns a boolean. Either way the compiler has no idea what to do with it, so you need to track it down. Try doing a find in your solution for "HasPreviousPage". See if it's been referenced anywhere, or where it is located.
Ctrl + F
Find What:
HasPreviousPage
Look In:
Entire Solution