|
Good Day All
I have a Generic function that in my Static Class. i have this Class in Silverlight
public static BitmapSource LoadImage(Byte[] imageBytes)
{
BitmapImage bmpImage = new BitmapImage();
MemoryStream mystream = new MemoryStream(imageBytes);
bmpImage.SetSource(mystream);
return bmpImage;
}
Now this looked fine for me until i had to bind an Image in Silverlight like this
PhotoHolder.Source =GenericMethods.LoadImage(model.imbPhoto);
The Images i have in the Database are Supported by silverlight they are jpg type.
and the Elelment that i am binding to look like this in Silverlight
<Image x:Name="PhotoHolder" Height="98" Width="102" OpacityMask="Black" Canvas.Left="141" Canvas.Top="30">
<Image.Effect>
<DropShadowEffect/>
</Image.Effect>
</Image>
so if i bind i get this Error
Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Where does the exception occur??
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
hi
it happen on this line
bmpImage.SetSource(mystream);
i have used the Correct Image Format that are supported in Silverlight.
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
It should work with valid JPEG bytes...
I tested your LoadImage() method but with JPEG bytes loaded from disk and it works fine:
private void loadButton_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog ofdlg = new OpenFileDialog();
ofdlg.Filter = "Image Files (*.jpg, *.jpeg, *.png)|*.jpg;*.jpeg;*.png";
if (true == ofdlg.ShowDialog())
{
long filelength = ofdlg.File.Length;
Byte[] imageBytes = new byte[filelength];
using (FileStream fs = ofdlg.File.OpenRead())
{
fs.Read(imageBytes, 0, (int)filelength);
}
PhotoHolder.Source = GenericMethods.LoadImage(imageBytes);
}
}
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Now i have a Different Error in the same place
Error HRESULT E_FAIL has been returned from a call to a COM component.
THANKS
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Silverlight COM component? hmm I have no idea. It works fine for me with valid JPEG files (and PNG files).
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
trying to copy and paste text containing hyperlink from one richtextbox to another with TextPointer position as parameter.
tried using the following code but couldn't figure out what the problem is. it did not work.
private Hyperlink GetHyperlinkAncestor(TextPointer position)
{
Inline parent = position.Parent as Inline;
while (parent != null && !(parent is Hyperlink))
{
parent = parent.Parent as Inline;
}
return parent as Hyperlink;
}
- Regards - J O N
A good thing is a bad thing if it keeps you from the best thing. - Dr. Adrian Rogers
|
|
|
|
|
I have created a WPF control, which I want to deploy to the user.
I need to create an installer for this control. Installer should create a custom tab in VS toolbox and place the control inside that tab, the way it is done by other WPF control installers (e.g., Telerik).
Any help/idea?
|
|
|
|
|
|
Many thanks for your reply. I tried google before asking question here, but none of them (including this one) could fulfill my requirement.
When I install Telerik with the help of their EXE, it just installs everything without being specific to any application. It puts that control into a specific tab in VS toolbox and also places it into 'Assets' tab of 'Expression Blend' without asking any question.
This .vsi file, including dialog box and messages, seems to be specific to Visual Studio and asks questions before installing.
|
|
|
|
|
This [^]could help you as well.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
Good Day All
I have another question. I have a Silverlight application and in one of the Silverlight pages i am hosting an Asp.net Page using a RadhtmlContainer(Telerik). I created a Cookie in Silverlight like this
public static void SetCookie(string key, string value)
{
DateTime expiration = DateTime.UtcNow + TimeSpan.FromDays(2000);
string cookie = String.Format("{0}={1};expires={2}", key, value, expiration.ToString("R"));
HtmlPage.Document.SetProperty("cookie", cookie);
}
and i have the same generic function to access it like this
public static string GetCookie(string key)
{
string[] cookies = HtmlPage.Document.Cookies.Split(';');
key += '=';
foreach (string cookie in cookies)
{
string cookieStr = cookie.Trim();
if (cookieStr.StartsWith(key, StringComparison.OrdinalIgnoreCase))
{
string[] vals = cookieStr.Split('=');
if (vals.Length >= 2)
{
return vals[1];
}
return string.Empty;
}
}
return null;
}
so i am trying to access this cookie in an asp.net page that is hosted on the the html Container , but i dont find the cookie.
Basically what i want to Achieve is
i want to access a value that is being created in Silverlight e.g "userid" "Username" normally i store it in the Cookie , so now i want to do a database insert , i need to do that insert from that asp.net page, but i cant get hold of that cookie value.
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
What do you see in HtmlPage.Document.Cookies when you enter the GetCookies method? It would really help if you set a breakpoint there and told us what was in that part? Plus, and I know this seems obvious, but make sure that the SetCookie method is called before you call GetCookies.
|
|
|
|
|
Good Evening Pete
Thank you for your kind response.
The First thing i do is to set the Cookie when the User has Just Logged in and after that that the User will be redirect to a Welcome page. There are Menu's that are visible for the User to select , and one of them will lead to a Silverlight page that will require the Cookie value that has been set at Login.
So the above explanation your last point that i should first set the Cookie and Access it later
To answer the first question about the htmlpage.Document.Cookies , it has an empty string i am not sure why.
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
From your description, the cookies are added by the website and not by Silverlight. It looks like you are trying to read the cookies created in the ASP.NET side, in your Silverlight code. According to MSDN[^], Cookies are disabled by default for security reasons. Use WebClient instead.
|
|
|
|
|
Can you pass the cookie value into the silverlight app as an initial parameter?
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
the thing is i want the value out of Silverlight to aspx
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
I have a SL site that is structured like
Corporate
- Company1
- Company2
- Company3
- Company4
Entry to the site is www.corporate.com
Each company now wants to basically skin their area of the site with thier company identity and to access their area directly skipping the corportate.com page. I know I can change skins (never having built a skin this is an assumption) so what is the recommended method of going directly to the company pages based on the URL.
All will use the same xbap, wcf and database it is just the entry point for the companies.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: what is the recommended method of going directly to the company pages based on the URL.
Easy using navigation![^]
Mycroft Holmes wrote: All will use the same xbap
XBAP? That's WPF...and not even recommended anymore
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: Easy using navigation![^]
Pfft alreay half way there I implemented navigation right from the start, just never went past the minimum required for our needs. thanks...
Mark Salsbery wrote: XBAP? That's WPF...and not even recommended anymore
What, that's what lives in my clientbin folder and thats what gets deployed (along with the dafault.aspx), when did they go out of fashion, link required. Your had better mean you are taking the mickey or I've got some serious reading to do.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: What, that's what lives in my clientbin folder and thats what gets deployed
Ohhh the XAP? XBAPs are WPF browser applications...Silverlight is recommended over XBAPs, although you can still do them.
And the smiley was just because I was nit-picking terms but not real seriously...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Oops - did not even notice the mistake thank ghu I thought I may have completely screwed up.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
It turns out that the link does not actually help me, I don't expose the url eg www.corporate.com?companyid=1 However I guess I should be able to use mymapper to hard code the url. Pick up www.corporate.com/CompanyName in mymapper and deal with it.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
The domain "www.corporate.com" doesn't need to be in the code, does it?
According to your original post, you should only need something like this
<navigation:Frame.UriMapper>
<uriMapper:UriMapper>
<uriMapper:UriMapping Uri="/Company1" MappedUri="/Views/Company1.xaml"/>
<uriMapper:UriMapping Uri="/Company2" MappedUri="/Views/Company2.xaml"/>
<uriMapper:UriMapping Uri="/Company3" MappedUri="/Views/Company3.xaml"/>
<uriMapper:UriMapping Uri="/Company4" MappedUri="/Views/Company4.xaml"/>
</uriMapper:UriMapper>
</navigation:Frame.UriMapper>
or better yet, to not hard-code company names in the code...
<navigation:Frame.UriMapper>
<uriMapper:UriMapper>
<uriMapper:UriMapping Uri="/{pageName}" MappedUri="/Views/{pageName}.xaml"/>
</uriMapper:UriMapper>
</navigation:Frame.UriMapper>
Mark Salsbery
Microsoft MVP - Visual C++
modified on Wednesday, May 25, 2011 4:36 PM
|
|
|
|
|
How do you eliminate the # requirement. Currently the nav wants
www.Corporate.com/#Company1
Never underestimate the power of human stupidity
RAH
|
|
|
|