I get InvalidOperationException when I try to use Metadatatype with a viewmodel
I have a model with certain properties. I use separated a class with the MetadataType to define requirements for properties. I also try to use the same metadata class with a viewmodel defining just a subset of properties. This is a simple example code of the
situation for clarification:
[MetadataType(typeof(Metadata))]
class ModelA
public class Metadata
[Required]
public object Property1 { get; set; }
[Required]
public object Property2 { get; set; }
public int Property1 { get; set; }
public int Property2 { get; set; }
[MetadataType(typeof(ModelA.Metadata))]
class ViewModelA
public int Property1 { get; set; }
The problem is when the razor engine tries to process the view, it throws an InvalidOperationException with the following error message:
The associated metadata type for type 'ViewModelA' contains the following unknown properties or fields: Property2.
Please make sure that the names of these members match the names of the properties on the main type.
In my understanding the problem here is that the metadata contains properties which the the view model does not. However, this way I don't really understand the advantages of having a metadata class. So my questions are
1) Is there a way to prevent of throwing this exception?
2) If not, what it the best pattern to this situation? (like using a model, a viewmodel, which contains the subset of the properties of the model, defining data annotations by keeping the DRY approach).
Hi,
This looks like a question about ASP.NET MVC. Best place to ask it would be on the asp.net forums on
http://www.asp.net.
Best Wishes!
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and
makes it easier for other visitors to find the resolution later.
Similar Messages
-
I bought a new Time Capsule 2Tb. I connected it to my internet router. I manage to set it up as base station but when i try to use it with time machine I always get the message "Check your IP addres"? What am I doing wrong? On my computer I have OSX 10.7.5
What IP address does the TC have and what IP does the computer have?
We need more info as we really have no idea what your network looks like.
Modem router, model, type of broadband?
TC setup as bridge or router?
Is the computer getting internet via the TC?
Are you using wireless or ethernet?
Have you set IPv6 correctly to local link in the computer on whichever network client is doing the connection?
Did this work the first time for backup and has now failed? If so simply reboot the TC. It is a constant bug that the TC is lost to the network. -
TS3274 Why do my pictures get larger when I try to use them as wallpaper on my IPAD?
Why do my pictures show up larger when I try to use them as wallpaper on my Ipad?
If you have Settings > General > Accessibility > Reduce Motion set 'off' then you will need to use a higher resolution version of your pictures, otherwise the parallax effect will zoom in.
From http://support.apple.com/kb/HT5595 :
When the parallax effect is on, you may notice the following:
Wallpaper, icons, and alerts shift slightly as you move your phone.
When you set a wallpaper in Settings > Wallpapers & Brightness, the photo or image will be slightly zoomed and can't be scaled to fit the screen.
If you zoom in, you will need to rescale your wallpaper to fit to the screen. You can't rescale certain photo formats, including landscape or square images. -
How do I resolve Licensing Error 6 when I try to use CS4 with new OS 10.8.4 system
I recently purchased a Mac Mini which uses OS X Mountain (10.8.4). (My old G5 with OS 10.5 had died.) When I purchased the Mac Mini I was told that my old Adobe Creative Suite 4 would still work. However, when I try to start up any application, but Photoshop for example, I am told that Licensing has stopped working and that I have Error 6. Does any one know how I can resolve this?
You need to contact Adobe about that. You will need CS6 or above.
-
Created a "Basic" key today, get 401 when I try to use REST services
I'm playing around with the source code from this tutorial:
http://azure.microsoft.com/en-us/documentation/articles/search-create-geospatial/
Instead of creating a Trial Key, I created a Basic Key. But now I get a 401 (unauthorized access) when I attempt to geocode some addresses.
How do I resolve this? It seems like I should be authorized. I just created the key today - is there a lag between when it is created and when it is valid? My understanding is that as long as I use less than 125,000 transactions a year, I should be able
to use Bing Maps for free?
I generated a Trial Key and it works fine with the demo.it looks like they are using the batch geocoding service. Basic and trial keys are limited to 50 addresses per batch geocode job. If you are passing more data than that, then that is likely the issue. Are you sure you are getting a 401 error and not some
other error?
http://rbrundritt.wordpress.com -
NOTEBOOK, RUNNING WIN 7 KEEPS GETTING ERROR WHEN I TRY TO USE TROUBLESHOOTING WIZARD
I HAVE NEVER USED THIS SITE BEFORE, SO HELP ME OUT AND BE PATIENT!! I HAVE A HP LAPTOP dv4-2058nr, RUNNING WIN 7 AND I CANNOT USE THE TROUBLESHOOTING WIZARD IN ANY FIELD. HOW CAN I FIX THIS. I HAVE LOOKED EVERYWHERE FOR HELP. I KEEP RECEIVING AN ERROR "YOU HAVE INCURRED AN UNEXPECTED ERROR. THE TROUBLESHOOTER CAN NOT CONTINUE."
Hey Gramtam,
What troubleshooter are you using that is failing? What are you using the troubleshooter for? Just want to make sure I fully understand your issue before continuing.
Thanks
Sean
-------------How do I give Kudos? | How do I mark a post as Solved? -------------------------------------------------------- -
I get error when i try to use update check
Error Message: There were problems checking for downloading, or installing this update. Firefox could not be updated because: "update XML File malformed (200)"
== This happened ==
Not sure how often
== updated to FireFox 3.6.3 / running MSOffice 2007OK, I checked for everything suggested in "AUS Update XML File Malformed 200" and none of the suggestions seemed applicable: I have no extension named Noscript, I can access secure sites, the url in "about:config" cannot be reset, I have no cookie named "aus2". --But the MERE ACT of trying these suggestions made my "XML File Malformed 200" message go away, at least temporarily -- I can now click Help/CheckForUpdates and the "Malformed" message does not appear, instead a message appears saying (words to the effect of) I have the most recent version, which is true by comparison of Help/About and the version number at the Firefox Updates site.
-
When I try to use iSight with iMovie and it says no camera available in iMovie '08
iSight won't connect in iMovie... HELP! I found an article regarding the issue but I think the version of iMovie was different than what I have because it really did me no good.
Here are my suggestions for your iMovie '08 problem.
One of them will resolve your trouble. Try them in
any order you like, testing camera function after
each one until you have found the one that worked.
• If you have not already done so, restart Mac and
try again. A simple restart often clears up minor
issues, including yours.
• I am using iMovie '11 with no problems. Some
problems have been reported with the iMovie 9.06.
However, I can't find compatibility info for ver 8.
If possible, consider updating to this latest iMovie:
http://www.apple.com/ilife/imovie/
• Try Apple's http://support.apple.com/kb/HT2090
suggestions. The specific "reset" procedure suggested
there for your particular MBP model often restores normal function.
(Apple has changed the built-in camera's name on newer Macs from "iSight" to "FaceTime" and then to "FaceTime HD." Regardless of the name of your built-in camera, the same info and troubleshooting applies.)
• Use your Mac's Disk Utility to repair permissions and then
download and apply the latest Combo Update, for your Mac OS,
the current one is at: http://support.apple.com/kb/DL1581
(yes, use this Combo even though you are already running 10.8.2)
Repair permissions again immediately following the system restart that completes the Combo update. Then check whether your Mac's > Software Update... menu command tell you that other updates are needed. If so, apply them and finish with another permissions repair.
• If you still have problems after properly applying the Combo,
try OS X's Recovery feature http://www.apple.com/macosx/recovery/
to repair your hard drive or, if all else fails, reinstall a fresh copy of OS X.
• Properly applying the latest Combo update or repairing or
reinstalling OS X can usually correct software problems.
However, if your trouble is caused by a hardware problem,
there are no user serviceable parts of your webcam.
For hardware help, contact an Apple-Authorized Service Provider for service.
Message was edited by: EZ Jim
Mac OSX 10.8.2 -
Firefox crashes when I try to use it with Windows7
I have sent crash reports and heard nothing back. HELP!!! Release me from IE!!! Please! Firefox won't even come up on my screen, just says it's crashed and a report will be sent. I've re-installed it 2X now, and it still won't work. It worked just fine on a previous (Win XP) computer, and I loved it, but my current computer came with Win 7, and Firefox doesn't work at all.
== Crash ID(s) ==
see Troubleshooting
== User Agent ==
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; GTB0.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; OfficeLiveConnector.1.4; OfficeLivePatch.1.3; .NET CLR 1.1.4322)Thanks for replying. There are 45 pages of report. I did make a pdf and will attach a picture of page 1.
-
My crash apprears before the browser opens and so i cannot submit the report with the built in tool.
Problem signature:
Problem Event Name: APPCRASH
Application Name: firefox.exe
Application Version: 2.0.0.4085
Application Timestamp: 4d77ab07
Fault Module Name: xfire_toucan64_44036.xll
Fault Module Version: 1.0.0.44036
Fault Module Timestamp: 4d685460
Exception Code: c0000005
Exception Offset: 00000000000065f6
OS Version: 6.1.7601.2.1.0.768.3
Locale ID: 2057
Additional Information 1: b7ec
Additional Information 2: b7ec39bb86f047f23e4546593c4d32e8
Additional Information 3: cbe3
Additional Information 4: cbe3f569a391f716bdc9010295cb018fI'm expreriencing the same conditions with the same environment. Windows 8, iTunes-64 11.1.2.32, iTunes Store with a processing bar up to 80 +/- and the POPUP MESSAGE OF "iTunes stopped working. The error ...."
I UNINSTALLED, iTUNES WITH NO POSITIVE RESULT. I CHECKED THE FIREWALL AND IS THE SAME DEFINITION AS THE PREVIOUS ITUNES VERSION.
My iTunes StoreS from my iPhones ARE OK.
I'm spending a lot of time of research for WINDOW'S iTUNE with no solutions.... -
My Ipod touch 4.2 will say it is connected to the wi fi but when I try and use it with an app it says it is not connected to the internet
- Do other devices successfully connect to the network?
- Did the iPod successfully connect to this network before?
- Does the iPod successfully connect to other networks?
Try:
- A reset. Nothing is lost
Reset iPod touch: Hold down the On/Off button and the Home button at the same time for at
least ten seconds, until the Apple logo appears.
- Power off and then back on your router
- Reset network settings: Settings>General>Reset>Reset Network Settings
-iOS: Troubleshooting Wi-Fi networks and connections -
When I try to use safari I get a message that states can not find server Xn--%20%20-1ia0eb092a
It sounds like you've got a messed-up homepage. Click the Safari menu, click Preferences, and under "Home page", re-type the page you'd prefer to load when Safari starts (eg "nytimes.com" or whatever). Close preferences and try again.
Matt -
I am having problems with the Preview application. When I try to use it to open a pdf document it gets hung-up and I have to select force quit to close it. Any ideas on how to resolve this problem? Thanks for any help
Can you open the Preview program without loading a file, like by itself?
If it doesn't load then I suspect a corrupt Preview preference file.
Deleting the System Preference or other .plist file
Can you open other files with Preview, like jpg's and images?
How about other PDFs? or is it just that one you have downloaded?
Run through this list of fixes
Step by Step to fix your Mac -
My iPhone5 network connection has been terrible for the past week and a half. My phone is no more than a year old so I don't see why it would be a problem with the phone. When I try to use the internet or look for apps or anything like that, anything that uses data really, it takes FOREVER if it even loads! Most of the time it won't even load. My network changes from LTE(which doesn't work well) to 3G(which works even less) and then to 1x(which basically doesn't work at all). This happens dozens of times a day. It's getting quite irritating. I've tried turning my phone off and letting it sit for a while and that does nothing. I'd really prefer NOT to restore my phone. What is the deal??!
Are you broadcasting your SSID? Sometimes this can cause a problem connecting. Is this Cisco router running any turbo modes or special preparatory protocols.
There are no know issues with Wi-Fi connectivity except on first connection; and the chance of 2 devices having the exact same issue is very unlikely. This sounds like something to do with your wireless router.
Have you tried to connect to another Wi-Fi hotspot elsewhere?
Do you have any 2.4 GHz wireless phones or security system that could interfere with connection? -
When I try to use the refine edge command I get this message could not complete the refine edge comm
when I try to use the refine edge command I get this message could not complete the refine edge command because of programe error
Quit the editor, then restart it while holding ctrl+alt+shift (command+option+shift on a mac). Keep the keys down till you see a window asking if you want to delete the settings file. You do.
Maybe you are looking for
-
After ios 8 update has anyones ipad started randomly selecting everything? Even after ios 8.0.1 update it has still continued to do the same thing making it immpossible to use ipad anymore. Has anyone had the same problem and/or knows how to fix this
-
Failed to install Flash Builder 4.5 in Mac OSX 10.7 Lion
Quickly after starting the installation procedure, the installer says the installation is cancelled and gives me the following error report: Exit Code: 24 -------------------------------------- Summary -------------------------------------- - 0 fatal
-
LQ02 Transaction not work in Back ground processing
Hi LQ02 transaction working well in forground process but not working for background process. I did the bdc and use call transaction to post WM-IM transaction. screen input as follows : Warehouse number Storage type Storage bin WM movement type Stora
-
Guys, Our requirement is that we have to perform a 562 on a non serialized material assign a serial number profile and perform a 561 to put it back to stock with a serial number. So when we do a 562 in IM a negative quant in 998 Delta is created.On p
-
At the PS prompt, I issued the following command: Get-ChildItem \\Somename\shared\folder\folder -Recurse Is Powershell storing my (object) result in some default temp variable (even though the result was ultimately pipelined to the screen) when I f