Link to home
Start Free TrialLog in
Avatar of CodeJunky
CodeJunkyFlag for United States of America

asked on

"getentryassembly is not a member of system.reflection.assembly"

Hi all,
I'm trying to create a Windows Phone Application in VS2013.
It seems every reference to a object from any library/Namespace I get an error that the object is not a member when it should be.  I add the imports for the namespace and objects and nothing helps.  If I create a an Windows App, non Windows Phone App, and use the same namespaces it works fine.

For instance.....
Imports System.Reflection

Public Function GetVersionNumber( as String)

Dim assem as Assembly = Assembley.GetEntryAssembly
...
...
end function

Assembley.GetEntryAssembly errors because the "GetEntryAssembly" is not a member.

I tried using different Framework versions also; without any luck.
Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

According to the documentation, GetEntryAssembly is not supported in .net framework for Windows Phone.
What about using GetExecutingAssembly instead?
http://msdn.microsoft.com/en-us/library/system.reflection.assembly.getexecutingassembly(v=vs.110).aspx
You have to be careful about what you use when working with Windows Phone or Windows Store (the new Windows 8 interface). The framework they use is not the same as the framework that is used on PCs for Windows Applications. Many namespaces and classes are not available. And for those that are, many methods, properties and events are missing.

As Jaime pointed out, you need to check the documentation carefully when working in an environment such as Windows Phone. Most pages in the documentation have a list of supported platforms toward the bottom of the page. When Windows Phone is not listed, it does not apply to your current project.

This being said, GetExecutingAssembly might not be what you are looking for if GetEntryAssembly was your first goal. If the code is running in a dll, GetExecutingAssembly will get information about the dll. If you want information about the application that is calling the dll, you can use GetCallingAssembly. According to the documentation, it is supported in Windows Phone since version 7.0.
Avatar of CodeJunky

ASKER

I'm in agreement with both of your points; but my problem is that the NameSpaces do not have methods, or I should say only a limited and useless amount of methods.  For Instance the System.Reflection.Assembly NameSpace only has three methods (Equals, Load, ReferenceEquals).  I'm seeing this with other NameSpaces as well. I do not see this happening in other types of projects and I've even tried it in C# with the same results.  I'm wondering if there is something wrong with my VS2013 enviornments.  I have tried this and other things on two different computers.  Would there be a reason that the methods would not be presenting themselves properly.

thanks.
My answer to your question was based on the documentation.

I created a new Windows Phone application on VS2013, and I end up having the same results as the ones you get. Even the sample code in the documentation is not acceptable.

Looking around, information is scarce, but it seems that the stuff has been dropped from the WinRT framework, and Windows Phone 8 applications are Store application. I have found something similar to the following in a few places:

http://social.msdn.microsoft.com/Forums/windowsapps/en-US/1f774a9e-39e0-4f3b-aead-661468465d51/reflectionassemblygetcallingassembly-gone-for-good?forum=winappswithcsharp

It looks as if the thing was removed, but the documentation was not updated.
I just wanted to get the application version.  Other code, I try seems to have the same issue.
Thanks very much though for trying the project yourself.  At least I can be failure confident that my development enviornment is stable.
ASKER CERTIFIED SOLUTION
Avatar of Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger)
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks very much, that did the trick.
Does anyone else find it frustrating that Microsoft isn't keeping there framework consistant?
Yes, it is frustrating, but Just think about it.

You do not have on a phone the same power, memory and disc space as you have on a computer. The OS cannot be sophisticated on such a little footprint, otherwise nothing would be left for the applications to run on.

What I find the most frustrating is when the documentation tells you that something is supported and it isn't.

The way they have been going for the last few years, it looks as if they want everybody to drop the desktop and fallback on WinRT and Azure. The competition is pushing at their back, and they end up going too fast and giving us tool that are not up to the task.

Not counting the fact that they keep changing the basics. I have not worked with phone applications, but did give a look at WinRT. They completely reworked the basic templates between Windows 8 and Windows 8.1. And when you hear about Visual Studio 2014, they are going Native .NET, once again, a new way to do things. This is the kind of thing that frustrates me.

When the framework came out in 2002, it was not perfect, but it had a solid base and simply evolved from there, every 2 years or so. Nowadays, every new version of Visual Studio brings new paradigms to do same things, showing indirectly that what was there before was crap. And they are coming every year. This is what frustrates me.
Yup.
Thanks very much again for you help.

Cheers.