|
You have the wrong forum, this forum is for C#
only two letters away from being an asset
|
|
|
|
|
Hello all
I have a mysql table with some rows in it that contain a path to a jpg file.
Here is a example of the path:
images/portfolio/lille_ilveaWebshop.jpg
The file excists on the webhost so that is not a problem.
I am loading the jpg file into a bitmap in a foreach.
It works fine when I am on a local server, but when I upload it to my webhost it says:
<quote>Server Error in '/' Application.
Out of memory.
Exception Details: System.OutOfMemoryException: Out of memory.
[OutOfMemoryException: Out of memory.]
System.Drawing.Bitmap..ctor(String filename) +376480
Referencer.Page_Load(Object sender, EventArgs e) +561
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627</quote>
I cant seem to figure out just why it would do that.
Here is the code I am using:
foreach (
DataRow Row in objPortFac.VisReference(refKatID).Rows)
{
// Create a new bitmap with the path from the row
// fldStortBillede is the field that contains the path
Bitmap objStortBillede = new Bitmap(Server.MapPath(Row["fldStortBillede"].ToString()));
// Dispose the bitmap after use
objStortBillede.Dispose();
}
Any suggestions?
|
|
|
|
|
Hi,
some image operators (e.g. Image.FromFile) throw an OOM Exception when the data is not valid. I don't know what Server.MapPath is assumed to do, nor how valid its result is. Split the statement in simpler ones and debug.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
The "new bitmap" needs a full path an images/something/blah.jpg doesnt work.
I am using Server.MapPath to find the full path
|
|
|
|
|
Have you checked the value of Server.MapPath(Row["fldStortBillede"].ToString() ?
MSDN: "For security reasons, the AspEnableParentPaths property has a default value set to FALSE. Scripts will not have access to the physical directory structure unless AspEnableParentPaths is set to TRUE."
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
The value on localhost is:
D:\Skole\DotNet\Portfolio\Portfolio\images\portfolio\stor_cronaldoHjemmeside.jpg
And on the webhost it is:
d:\web\localuser\dumpen.dk\public_html\images\portfolio\stor_cronaldoHjemmeside.jpg
It works with 2 or 3 images but with more then that the error occours
|
|
|
|
|
is it always the same image that fails, if so it got damaged. try changing the order just to see what happens.
are these images large, compared to your system (is it a mobile Windows system with limited RAM?).
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
I'm also having the same Problem.
In my local it is working properly. But in server, it is throwing out of memory exception.
i got this exception even though the memory is available in server.
Graphics g = Graphics.FromImage(source);
try
{
g.DrawImageUnscaled(original, 0, 0);
}
finally
{
((IDisposable)g).Dispose();
}
This is the code i'm using.
Any solutions to this issue?
Thanks in advance
|
|
|
|
|
insufficient information.
IMO DrawImageUnscaled is more critical than DrawImage, as the resolution may be screwed inside the image (both source and original). Try DrawImage instead. And log all image parameters, to see if there ever is anything abnormal.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Luc Pattyn wrote: some image operators (e.g. Image.FromFile) throw an OOM Exception when the data is not valid. Nice. 8 years later, and this post was quite relevant for me, in that it really wasn't an OOM error.
|
|
|
|
|
Today, I need to fix that statement; it should read:
some image operators (e.g. Image.FromFile) MAY throw an OOM Exception when the data is not valid.
There is no guarantee an OOM will occur on every damaged image!
Luc Pattyn [My Articles]
The Windows 11 taskbar is a disgrace; a third-party add-on is needed to reverse the deterioration. I decline such a downgrade.
|
|
|
|
|
Is there an already implemented way to get all the nodes within a treeview? including the childs,
for example if you have a treeview like
+father
++child
I would like to get a TreeNodeCollection with this two..
Should I create my own MyTreeView : TreeView implementing a method?
|
|
|
|
|
If I understand what you want correctly, without walking the entire tree yourself, no there isn't.
Every TreeNode supports its own TreeNodeCollection. So you just have to walk the entire collection of each node and add it to your seperate TreeNodeCollection.
|
|
|
|
|
No, I don't think such method exists. You don't have to create a custom tree view for this, just write an extension method[^] (assuming you're using C# 3.0).
Eslam Afifi
|
|
|
|
|
public void GetNodes(TreeNodeCollection tc)
{
foreach (TreeNode tn in tc)
{
MessageBox.Show(tn.Text);
GetNodes(tn.Nodes);
}
}
I know nothing , I know nothing ...
|
|
|
|
|
Ok I did it this way, any comments?
<pre>
public class G31TreeView : TreeView
{
private static TreeNodeCollection allNodes;
/// <summary>
/// Returns all nodes, including childs (a flattened tree)
/// </summary>
public TreeNodeCollection AllNodes {
get
{
allNodes = new TreeNodeCollection();
return BuildAllNodesList(this.Nodes);
}
}
/// <summary>
/// Builds the list of all nodes recursively
/// </summary>
/// <param name="tnc">The initial node to begin the build</param>
private void BuildAllNodesList(TreeNodeCollection tnc)
{
foreach (TreeNode tn in tnc)
{
// If the list hasnt added the current node we add it.
if (!allnodes.Contains(tn))
{
allnodes.Add(tn);
}
// Childs of current tn
BuildAllNodesList(tn);
}
}
}
</pre>
|
|
|
|
|
That'll work, but there's really no need for the check to see if the node exists already. A TreeNode cannot exist in more than one place in the tree.
|
|
|
|
|
The project in which i am doing, i need to dynamically change the font of the label control and i did it and i saved the values in the database (ms-access). And now i need to retrieve those values from the database . So, i have retrieved the values but how can i apply those retrieved values to the label font dynamiacally. Give me some solution.
|
|
|
|
|
myLabel.Font = new Font(....................);
Look up the documentation for the Font constructor. There are loads of them, which one to use will depend on what information you saved in your database.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
|
I have written a COM DLL which gives the
out parameter as BSTR**(Typically 2D Char Array).
This COM function will fill the values of BSTR** variable.
I am able to use this function sucessfully in MFC Application.
But I face problem in using it in C#.
The Sample code is as follows:
///////////COM Function////////////////////////////////////////
STDMETHODIMP CSampleTest::GetAllDeviceList2(BSTR** szMaclist)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
for(int i=0;i<10;i++)
{
szMaclist[i] = new BSTR[100];
wchar_t *szTmp = new wchar_t[100];
wsprintf(szTmp,L"Device%d",i+1);
*szMaclist[i]=SysAllocString(szTmp);
}
return S_OK;
}
///////////////////////////////////////////////////////////////
I acessed this in VC++ by,
BSTR **szMaclist = new BSTR*[10];
CoInitialize(NULL);
HRESULT hr = CoCreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER,iid,(void**)&pText);
if( SUCCEEDED(hr) )
{
pText->GetAllDeviceList2(szMaclist);
pText->Release();
}
and i am sucessful in acessing this function in MFC Application.
Can anyone tell me how to acess GetAllDeviceList2() function in c#.
|
|
|
|
|
Generate a COM Class Wrapper (CCW)[^] then add reference to that in your .net project and invoke. Probably you will get a 2D array of object (i.e. object[][] ) for that BSTR**.
Moim Hossain
R&D Project Manager
BlueCielo ECM Solutions BV
|
|
|
|
|
If you don't mind could you please provide me the code snippet
for the above.
|
|
|
|
|
when a PDF file is opened, AcroRd32.exe is started automatically, and we get the GUID value of that adobe reader.
In c#, can't we get the document associated with the GUID value, I mean the total PDF file which is opened in adobe reader at runtime.
Here I'm struck up in code, can anyone suggest how to where I was missing something.
Acrobat.CAcroAVDoc AcroAvDoc;
Type AcrobatCAcroType;
AcrobatCAcroType = Type.GetTypeFromCLSID(new Guid("{CA8A9780-280D-11CF-A24D-444553540000}"));
Object obj = Activator.CreateInstance(AcrobatCAcroType);
AcroAvDoc = (Acrobat.CAcroAVDoc)obj;
I think I can get the full PDF document with AcroAvDoc.GetPDDoc();
Thank you...
|
|
|
|
|
Hello,
i can't find function that handles a convertion to ipicture object to byte[]
greetings,
Sander
|
|
|
|